From d45c9baac0624b19d29d1a629b2f4889f0613c65 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Sun, 5 Dec 2021 11:48:09 +0800 Subject: [PATCH 1/2] Unify the description of quiet flag Signed-off-by: hi-rustin --- src/bin/cargo/commands/tree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs index 6b996d66fa2..08352b451dc 100644 --- a/src/bin/cargo/commands/tree.rs +++ b/src/bin/cargo/commands/tree.rs @@ -12,7 +12,7 @@ use std::str::FromStr; pub fn cli() -> App { subcommand("tree") .about("Display a tree visualization of a dependency graph") - .arg(opt("quiet", "Suppress status messages").short("q")) + .arg(opt("quiet", "Do not print cargo log messages").short("q")) .arg_manifest_path() .arg_package_spec_no_all( "Package to be used as the root of the tree", From a3e3ff99c9c1f20a8ed33a66bcd3a09549c1f971 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 6 Dec 2021 11:01:47 +0800 Subject: [PATCH 2/2] Add arg_quiet Signed-off-by: hi-rustin --- src/bin/cargo/cli.rs | 2 +- src/bin/cargo/commands/bench.rs | 2 +- src/bin/cargo/commands/build.rs | 2 +- src/bin/cargo/commands/check.rs | 2 +- src/bin/cargo/commands/clean.rs | 2 +- src/bin/cargo/commands/doc.rs | 2 +- src/bin/cargo/commands/fetch.rs | 2 +- src/bin/cargo/commands/fix.rs | 2 +- src/bin/cargo/commands/generate_lockfile.rs | 2 +- src/bin/cargo/commands/init.rs | 2 +- src/bin/cargo/commands/install.rs | 2 +- src/bin/cargo/commands/locate_project.rs | 2 +- src/bin/cargo/commands/login.rs | 2 +- src/bin/cargo/commands/logout.rs | 2 +- src/bin/cargo/commands/metadata.rs | 2 +- src/bin/cargo/commands/new.rs | 2 +- src/bin/cargo/commands/owner.rs | 2 +- src/bin/cargo/commands/package.rs | 2 +- src/bin/cargo/commands/pkgid.rs | 2 +- src/bin/cargo/commands/publish.rs | 2 +- src/bin/cargo/commands/read_manifest.rs | 2 +- src/bin/cargo/commands/run.rs | 2 +- src/bin/cargo/commands/rustc.rs | 2 +- src/bin/cargo/commands/rustdoc.rs | 2 +- src/bin/cargo/commands/search.rs | 2 +- src/bin/cargo/commands/tree.rs | 2 +- src/bin/cargo/commands/uninstall.rs | 2 +- src/bin/cargo/commands/update.rs | 2 +- src/bin/cargo/commands/vendor.rs | 2 +- src/bin/cargo/commands/verify_project.rs | 2 +- src/bin/cargo/commands/version.rs | 2 +- src/bin/cargo/commands/yank.rs | 2 +- src/cargo/util/command_prelude.rs | 4 ++++ 33 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index d4da7276b25..c3707df1dfe 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -453,7 +453,7 @@ See 'cargo help ' for more information on a specific command.\n", .multiple(true) .global(true), ) - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg( opt("color", "Coloring: auto, always, never") .value_name("WHEN") diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index 3c6956c7f90..39ec1be2253 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -5,7 +5,7 @@ pub fn cli() -> App { subcommand("bench") .setting(AppSettings::TrailingVarArg) .about("Execute all benchmarks of a local package") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg( Arg::with_name("BENCHNAME") .help("If specified, only run benches containing this string in their names"), diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index 678d62e2c88..ad6705119a9 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -7,7 +7,7 @@ pub fn cli() -> App { // subcommand aliases are handled in aliased_command() // .alias("b") .about("Compile a local package and all of its dependencies") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_package_spec( "Package to build (see `cargo help pkgid`)", "Build all packages in the workspace", diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs index 1ad7f76e074..3be146c6d26 100644 --- a/src/bin/cargo/commands/check.rs +++ b/src/bin/cargo/commands/check.rs @@ -7,7 +7,7 @@ pub fn cli() -> App { // subcommand aliases are handled in aliased_command() // .alias("c") .about("Check a local package and all of its dependencies for errors") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_package_spec( "Package(s) to check", "Check all packages in the workspace", diff --git a/src/bin/cargo/commands/clean.rs b/src/bin/cargo/commands/clean.rs index bc390be74d9..c966c65f13b 100644 --- a/src/bin/cargo/commands/clean.rs +++ b/src/bin/cargo/commands/clean.rs @@ -6,7 +6,7 @@ use cargo::util::print_available_packages; pub fn cli() -> App { subcommand("clean") .about("Remove artifacts that cargo has generated in the past") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_package_spec_simple("Package to clean artifacts for") .arg_manifest_path() .arg_target_triple("Target triple to clean output for") diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs index 37ca37030a2..21d561394ca 100644 --- a/src/bin/cargo/commands/doc.rs +++ b/src/bin/cargo/commands/doc.rs @@ -7,7 +7,7 @@ pub fn cli() -> App { // subcommand aliases are handled in aliased_command() // .alias("d") .about("Build a package's documentation") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(opt( "open", "Opens the docs in a browser after the operation", diff --git a/src/bin/cargo/commands/fetch.rs b/src/bin/cargo/commands/fetch.rs index eb39b57070f..ff3fcbec5da 100644 --- a/src/bin/cargo/commands/fetch.rs +++ b/src/bin/cargo/commands/fetch.rs @@ -6,7 +6,7 @@ use cargo::ops::FetchOptions; pub fn cli() -> App { subcommand("fetch") .about("Fetch dependencies of a package from the network") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .arg_target_triple("Fetch dependencies for the target triple") .after_help("Run `cargo help fetch` for more detailed information.\n") diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 7db1abe38df..85cf955e433 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, CompileFilter, FilterRule, LibRule}; pub fn cli() -> App { subcommand("fix") .about("Automatically fix lint warnings reported by rustc") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_package_spec( "Package(s) to fix", "Fix all packages in the workspace", diff --git a/src/bin/cargo/commands/generate_lockfile.rs b/src/bin/cargo/commands/generate_lockfile.rs index 19f2c63a893..1eebdbd418c 100644 --- a/src/bin/cargo/commands/generate_lockfile.rs +++ b/src/bin/cargo/commands/generate_lockfile.rs @@ -5,7 +5,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("generate-lockfile") .about("Generate the lockfile for a package") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .after_help("Run `cargo help generate-lockfile` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/init.rs b/src/bin/cargo/commands/init.rs index 0cc0d072fe3..257d30756f5 100644 --- a/src/bin/cargo/commands/init.rs +++ b/src/bin/cargo/commands/init.rs @@ -5,7 +5,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("init") .about("Create a new cargo package in an existing directory") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("path").default_value(".")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 798a08d8d57..79be166e4ee 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -7,7 +7,7 @@ use cargo::util::IntoUrl; pub fn cli() -> App { subcommand("install") .about("Install a Rust binary. Default location is $HOME/.cargo/bin") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("crate").empty_values(false).multiple(true)) .arg( opt("version", "Specify a version to install") diff --git a/src/bin/cargo/commands/locate_project.rs b/src/bin/cargo/commands/locate_project.rs index 5701de93dee..a045e14548b 100644 --- a/src/bin/cargo/commands/locate_project.rs +++ b/src/bin/cargo/commands/locate_project.rs @@ -6,7 +6,7 @@ use serde::Serialize; pub fn cli() -> App { subcommand("locate-project") .about("Print a JSON representation of a Cargo.toml file's location") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .arg( opt( diff --git a/src/bin/cargo/commands/login.rs b/src/bin/cargo/commands/login.rs index a589a0c9e40..aae218f770b 100644 --- a/src/bin/cargo/commands/login.rs +++ b/src/bin/cargo/commands/login.rs @@ -8,7 +8,7 @@ pub fn cli() -> App { "Save an api token from the registry locally. \ If token is not specified, it will be read from stdin.", ) - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("token")) // --host is deprecated (use --registry instead) .arg( diff --git a/src/bin/cargo/commands/logout.rs b/src/bin/cargo/commands/logout.rs index 47456f8f7ad..4ce9498e7e1 100644 --- a/src/bin/cargo/commands/logout.rs +++ b/src/bin/cargo/commands/logout.rs @@ -4,7 +4,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("logout") .about("Remove an API token from the registry locally") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .after_help("Run `cargo help logout` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/metadata.rs b/src/bin/cargo/commands/metadata.rs index b475816aa67..66e856b48e7 100644 --- a/src/bin/cargo/commands/metadata.rs +++ b/src/bin/cargo/commands/metadata.rs @@ -8,7 +8,7 @@ pub fn cli() -> App { the concrete used versions including overrides, \ in machine-readable format", ) - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_features() .arg(multi_opt( "filter-platform", diff --git a/src/bin/cargo/commands/new.rs b/src/bin/cargo/commands/new.rs index 0d6ce42dba9..c1828fd8637 100644 --- a/src/bin/cargo/commands/new.rs +++ b/src/bin/cargo/commands/new.rs @@ -5,7 +5,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("new") .about("Create a new cargo package at ") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("path").required(true)) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() diff --git a/src/bin/cargo/commands/owner.rs b/src/bin/cargo/commands/owner.rs index 7adfbb705d5..fd3d6169b29 100644 --- a/src/bin/cargo/commands/owner.rs +++ b/src/bin/cargo/commands/owner.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, OwnersOptions}; pub fn cli() -> App { subcommand("owner") .about("Manage the owners of a crate on the registry") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("crate")) .arg( multi_opt( diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index f71d2fdb965..875a0b0ab54 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, PackageOpts}; pub fn cli() -> App { subcommand("package") .about("Assemble the local package into a distributable tarball") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg( opt( "list", diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs index 46c27882c52..5bf7d8c2219 100644 --- a/src/bin/cargo/commands/pkgid.rs +++ b/src/bin/cargo/commands/pkgid.rs @@ -6,7 +6,7 @@ use cargo::util::print_available_packages; pub fn cli() -> App { subcommand("pkgid") .about("Print a fully qualified package specification") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("spec")) .arg_package("Argument to get the package ID specifier for") .arg_manifest_path() diff --git a/src/bin/cargo/commands/publish.rs b/src/bin/cargo/commands/publish.rs index f94fbd13461..2c1dce9f4b5 100644 --- a/src/bin/cargo/commands/publish.rs +++ b/src/bin/cargo/commands/publish.rs @@ -5,7 +5,7 @@ use cargo::ops::{self, PublishOpts}; pub fn cli() -> App { subcommand("publish") .about("Upload a package to the registry") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_index() .arg(opt("token", "Token to use when uploading").value_name("TOKEN")) .arg(opt( diff --git a/src/bin/cargo/commands/read_manifest.rs b/src/bin/cargo/commands/read_manifest.rs index 0d602ee1df5..86867152c93 100644 --- a/src/bin/cargo/commands/read_manifest.rs +++ b/src/bin/cargo/commands/read_manifest.rs @@ -9,7 +9,7 @@ Print a JSON representation of a Cargo.toml manifest. Deprecated, use `cargo metadata --no-deps` instead.\ ", ) - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() } diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index acc09bcb75e..75f317c94b6 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -10,7 +10,7 @@ pub fn cli() -> App { // .alias("r") .setting(AppSettings::TrailingVarArg) .about("Run a binary or example of the local package") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true)) .arg_targets_bin_example( "Name of the bin target to run", diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index 54b4e205ab5..750505dc04e 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -9,7 +9,7 @@ pub fn cli() -> App { subcommand("rustc") .setting(AppSettings::TrailingVarArg) .about("Compile a package, and pass extra options to the compiler") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true).help("Rustc flags")) .arg_package("Package to build") .arg_jobs() diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index 9dffd22a239..a6a32440ccb 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -6,7 +6,7 @@ pub fn cli() -> App { subcommand("rustdoc") .setting(AppSettings::TrailingVarArg) .about("Build a package's documentation, using specified custom flags.") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("args").multiple(true)) .arg(opt( "open", diff --git a/src/bin/cargo/commands/search.rs b/src/bin/cargo/commands/search.rs index 3ee9359400f..fecca594bdf 100644 --- a/src/bin/cargo/commands/search.rs +++ b/src/bin/cargo/commands/search.rs @@ -7,7 +7,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("search") .about("Search packages in crates.io") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("query").multiple(true)) .arg_index() .arg( diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs index 08352b451dc..f45e21ba619 100644 --- a/src/bin/cargo/commands/tree.rs +++ b/src/bin/cargo/commands/tree.rs @@ -12,7 +12,7 @@ use std::str::FromStr; pub fn cli() -> App { subcommand("tree") .about("Display a tree visualization of a dependency graph") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .arg_package_spec_no_all( "Package to be used as the root of the tree", diff --git a/src/bin/cargo/commands/uninstall.rs b/src/bin/cargo/commands/uninstall.rs index 77bba4714e5..f228af195d3 100644 --- a/src/bin/cargo/commands/uninstall.rs +++ b/src/bin/cargo/commands/uninstall.rs @@ -5,7 +5,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("uninstall") .about("Remove a Rust binary") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("spec").multiple(true)) .arg_package_spec_simple("Package to uninstall") .arg(multi_opt("bin", "NAME", "Only uninstall the binary NAME")) diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index fce9639e287..c1041310bfb 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -6,7 +6,7 @@ use cargo::util::print_available_packages; pub fn cli() -> App { subcommand("update") .about("Update dependencies as recorded in the local lock file") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(opt("workspace", "Only update the workspace packages").short("w")) .arg_package_spec_simple("Package to update") .arg(opt( diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs index 42eb501a547..9a96af613d4 100644 --- a/src/bin/cargo/commands/vendor.rs +++ b/src/bin/cargo/commands/vendor.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; pub fn cli() -> App { subcommand("vendor") .about("Vendor all dependencies for a project locally") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .arg(Arg::with_name("path").help("Where to vendor crates (`vendor` by default)")) .arg( diff --git a/src/bin/cargo/commands/verify_project.rs b/src/bin/cargo/commands/verify_project.rs index d52694687bb..4a5cf68c1e2 100644 --- a/src/bin/cargo/commands/verify_project.rs +++ b/src/bin/cargo/commands/verify_project.rs @@ -6,7 +6,7 @@ use std::process; pub fn cli() -> App { subcommand("verify-project") .about("Check correctness of crate manifest") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg_manifest_path() .after_help("Run `cargo help verify-project` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/version.rs b/src/bin/cargo/commands/version.rs index ed2b3191135..8518877893a 100644 --- a/src/bin/cargo/commands/version.rs +++ b/src/bin/cargo/commands/version.rs @@ -4,7 +4,7 @@ use crate::command_prelude::*; pub fn cli() -> App { subcommand("version") .about("Show version information") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .after_help("Run `cargo help version` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/yank.rs b/src/bin/cargo/commands/yank.rs index d371088f013..9bf3fa02cc0 100644 --- a/src/bin/cargo/commands/yank.rs +++ b/src/bin/cargo/commands/yank.rs @@ -5,7 +5,7 @@ use cargo::ops; pub fn cli() -> App { subcommand("yank") .about("Remove a pushed crate from the index") - .arg(opt("quiet", "Do not print cargo log messages").short("q")) + .arg_quiet() .arg(Arg::with_name("crate")) .arg( opt("vers", "The version to yank or un-yank") diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 31ceb737cd4..2c46b6edfaf 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -236,6 +236,10 @@ pub trait AppExt: Sized { "Outputs a future incompatibility report at the end of the build (unstable)", )) } + + fn arg_quiet(self) -> Self { + self._arg(opt("quiet", "Do not print cargo log messages").short("q")) + } } impl AppExt for App {