use eyre::Result;
use crate::cli::args::BackendArg;
use crate::config::Config;
use crate::config::config_file::ConfigFile;
#[derive(Debug, clap::Args)]
#[clap(visible_aliases = ["rm", "remove", "delete", "del"], after_long_help = AFTER_LONG_HELP, verbatim_doc_comment)]
pub struct ToolAliasUnset {
pub plugin: BackendArg,
pub alias: Option<String>,
}
impl ToolAliasUnset {
pub async fn run(self) -> Result<()> {
let mut global_config = Config::get().await?.global_config()?;
match self.alias {
None => {
global_config.remove_backend_alias(&self.plugin)?;
}
Some(ref alias) => {
global_config.remove_alias(&self.plugin, alias)?;
}
}
global_config.save()
}
}
static AFTER_LONG_HELP: &str = color_print::cstr!(
r#"<bold><underline>Examples:</underline></bold>
$ <bold>mise tool-alias unset maven</bold>
$ <bold>mise tool-alias unset node lts-jod</bold>
"#
);