From 1376f4007f96fe9479d3d3778491385c1597982b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 8 Mar 2018 17:10:28 +0300 Subject: [PATCH] Move uninstall to clap --- src/bin/cargo.rs | 4 ++-- src/bin/cli/mod.rs | 8 ++++++++ src/bin/cli/uninstall.rs | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/bin/cli/uninstall.rs diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index 46e77ac6c..fe33c410c 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -92,7 +92,7 @@ fn main() { "build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" | "git-checkout" | "init" | "install" | "locate-project" | "login" | "metadata" | "new" | "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" | - "rustc" | "rustdoc" | "search" | "test" => true, + "rustc" | "rustdoc" | "search" | "test" | "uninstall" => true, _ => false }); @@ -145,7 +145,7 @@ macro_rules! each_subcommand{ // $mac!(rustdoc); // $mac!(search); // $mac!(test); - $mac!(uninstall); +// $mac!(uninstall); $mac!(update); $mac!(verify_project); $mac!(version); diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 0a8a4bb0c..f60ef4a15 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -593,6 +593,12 @@ about this warning."; } }; } + ("uninstall", Some(args)) => { + let root = args.value_of("root"); + let specs = args.values_of("spec").unwrap_or_default().collect(); + ops::uninstall(root, specs, values(args, "bin"), config)?; + return Ok(()); + } _ => return Ok(()) } } @@ -686,6 +692,7 @@ See 'cargo help ' for more information on a specific command. rustdoc::cli(), search::cli(), test::cli(), + uninstall::cli(), ]) ; app @@ -718,6 +725,7 @@ mod rustc; mod rustdoc; mod search; mod test; +mod uninstall; mod utils { use clap::{self, SubCommand, AppSettings}; diff --git a/src/bin/cli/uninstall.rs b/src/bin/cli/uninstall.rs new file mode 100644 index 000000000..2c407326d --- /dev/null +++ b/src/bin/cli/uninstall.rs @@ -0,0 +1,21 @@ +use super::utils::*; + +pub fn cli() -> App { + subcommand("uninstall") + .about("Remove a Rust binary") + .arg(Arg::with_name("spec").multiple(true)) + .arg( + opt("bin", "Only uninstall the binary NAME") + .value_name("NAME").multiple(true) + ) + .arg( + opt("root", "Directory to uninstall packages from") + .value_name("DIR") + ) + .after_help("\ +The argument SPEC is a package id specification (see `cargo help pkgid`) to +specify which crate should be uninstalled. By default all binaries are +uninstalled for a crate but the `--bin` and `--example` flags can be used to +only uninstall particular binaries. +") +} -- 2.30.2