From: Aleksey Kladov Date: Wed, 7 Mar 2018 07:57:51 +0000 (+0300) Subject: Move clean to clap X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~47^2~65 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=51f1c4a8ae434dd910b529abefe607e6498fcb0e;p=cargo.git Move clean to clap --- diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index f3b458b01..485dc9d62 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -89,7 +89,7 @@ fn main() { }; let is_clapified = ::std::env::args().any(|arg| match arg.as_ref() { - "build" | "bench" | "check" => true, + "build" | "bench" | "check" | "clean" => true, _ => false }); @@ -120,7 +120,7 @@ macro_rules! each_subcommand{ // $mac!(bench); // $mac!(build); // $mac!(check); - $mac!(clean); +// $mac!(clean); $mac!(doc); $mac!(fetch); $mac!(generate_lockfile); diff --git a/src/bin/cli/bench.rs b/src/bin/cli/bench.rs index b11266cd6..d52f45ec3 100644 --- a/src/bin/cli/bench.rs +++ b/src/bin/cli/bench.rs @@ -37,7 +37,7 @@ pub fn cli() -> App { ) .arg_jobs() .arg_features() - .arg_target_triple() + .arg_target_triple("Build for the target triple") .arg_manifest_path() .arg_message_format() .arg( diff --git a/src/bin/cli/build.rs b/src/bin/cli/build.rs index 07691780f..645be8279 100644 --- a/src/bin/cli/build.rs +++ b/src/bin/cli/build.rs @@ -23,7 +23,7 @@ pub fn cli() -> App { ) .arg_release("Build artifacts in release mode, with optimizations") .arg_features() - .arg_target_triple() + .arg_target_triple("Build for the target triple") .arg_manifest_path() .arg_message_format() .arg_locked() diff --git a/src/bin/cli/check.rs b/src/bin/cli/check.rs index 344b7c830..db7277748 100644 --- a/src/bin/cli/check.rs +++ b/src/bin/cli/check.rs @@ -27,7 +27,7 @@ pub fn cli() -> App { .value_name("PROFILE") ) .arg_features() - .arg_target_triple() + .arg_target_triple("Check for the target triple") .arg_manifest_path() .arg_message_format() .arg_locked() diff --git a/src/bin/cli/clean.rs b/src/bin/cli/clean.rs new file mode 100644 index 000000000..db494419e --- /dev/null +++ b/src/bin/cli/clean.rs @@ -0,0 +1,20 @@ +use super::utils::*; + +pub fn cli() -> App { + subcommand("clean") + .about("Remove artifacts that cargo has generated in the past") + .arg( + opt("package", "Package to clean artifacts for") + .short("p").value_name("SPEC").multiple(true) + ) + .arg_manifest_path() + .arg_target_triple("Target triple to clean output for (default all)") + .arg_release("Whether or not to clean release artifacts") + .arg_locked() + .after_help("\ +If the --package argument is given, then SPEC is a package id specification +which indicates which package's artifacts should be cleaned out. If it is not +given, then all packages' artifacts are removed. For more information on SPEC +and its format, see the `cargo help pkgid` command. +") +} diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index 71c7aeecc..7edf41ff5 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -158,6 +158,18 @@ pub fn do_main(config: &mut Config) -> Result<(), CliError> { ops::compile(&ws, &compile_opts)?; return Ok(()); } + ("clean", Some(args)) => { + config_from_args(config, args)?; + let ws = workspace_from_args(config, args)?; + let opts = ops::CleanOptions { + config, + spec: &values(args, "package"), + target: args.value_of("target"), + release: args.is_present("release"), + }; + ops::clean(&ws, &opts)?; + return Ok(()); + } _ => return Ok(()) } } @@ -223,6 +235,7 @@ See 'cargo help ' for more information on a specific command. bench::cli(), build::cli(), check::cli(), + clean::cli(), ]) ; app @@ -231,6 +244,7 @@ See 'cargo help ' for more information on a specific command. mod bench; mod build; mod check; +mod clean; mod utils { use clap::{self, SubCommand, AppSettings}; @@ -293,8 +307,8 @@ mod utils { self._arg(opt("release", release)) } - fn arg_target_triple(self) -> Self { - self._arg(opt("target", "Build for the target triple").value_name("TRIPLE")) + fn arg_target_triple(self, target: &'static str) -> Self { + self._arg(opt("target", target).value_name("TRIPLE")) } fn arg_manifest_path(self) -> Self {