Move uninstall to clap
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 8 Mar 2018 14:10:28 +0000 (17:10 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 8 Mar 2018 20:30:47 +0000 (23:30 +0300)
src/bin/cargo.rs
src/bin/cli/mod.rs
src/bin/cli/uninstall.rs [new file with mode: 0644]

index 46e77ac6c3e9ac8cf552d6779b467dc5fa637132..fe33c410c4269b5ce50d3779ca5b71ef5ffca3bb 100644 (file)
@@ -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);
index 0a8a4bb0cd67cb4ad2e8960120b83a962d340e2d..f60ef4a15a8801b0761a5ab103117a802bf972f2 100644 (file)
@@ -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 <command>' 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 (file)
index 0000000..2c40732
--- /dev/null
@@ -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.
+")
+}