From c704ab3c82fedf3f909e9f1c8f77a0dbe50b0d29 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Fri, 4 Oct 2019 21:53:22 +0200 Subject: [PATCH] Add package uninstall option. Fix #63 --- src/main.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2cd9e96..0620c70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,11 @@ fn main() { .arg(Arg::with_name("package_name") .help("Package name")); + let uninstall_subcommand = SubCommand::with_name("uninstall") + .about("Remove an installed package. Equivalent to 'espanso package uninstall'") + .arg(Arg::with_name("package_name") + .help("Package name")); + let mut clap_instance = App::new("espanso") .version(VERSION) .author("Federico Terzi") @@ -122,19 +127,18 @@ fn main() { .subcommand(SubCommand::with_name("package") .about("Espanso package manager commands") .subcommand(install_subcommand.clone()) + .subcommand(uninstall_subcommand.clone()) .subcommand(SubCommand::with_name("list") .about("List all installed packages") .arg(Arg::with_name("full") .help("Print all package info") .long("full"))) - .subcommand(SubCommand::with_name("remove") - .about("Remove an installed package") - .arg(Arg::with_name("package_name") - .help("Package name"))) + .subcommand(SubCommand::with_name("refresh") .about("Update espanso package index")) ) - .subcommand(install_subcommand); + .subcommand(install_subcommand) + .subcommand(uninstall_subcommand); let matches = clap_instance.clone().get_matches(); @@ -223,12 +227,17 @@ fn main() { return; } + if let Some(matches) = matches.subcommand_matches("uninstall") { + remove_package_main(config_set, matches); + return; + } + if let Some(matches) = matches.subcommand_matches("package") { if let Some(matches) = matches.subcommand_matches("install") { install_main(config_set, matches); return; } - if let Some(matches) = matches.subcommand_matches("remove") { + if let Some(matches) = matches.subcommand_matches("uninstall") { remove_package_main(config_set, matches); return; }