Skip to content

Commit 2cbbf6e

Browse files
committed
Auto merge of #12959 - ehuss:quiet-global, r=epage
Fix --quiet being used with nested subcommands. This fixes an issue where `--quiet` doesn't work with commands that have subcommands. This is because `config_configure` only looks at the global and top-level subcommand, and not deeper subcommands. The issue was that `--quiet` was not defined as a global flag. This was changed in #6358 in order to give a better help message for `cargo test --quiet`. I don't remember if clap just didn't support overriding at the time, or if we just didn't know how it worked. Anyways, it seems to work to override it now, so I think it should be fine to mark it as global. This should bring in `--quiet` more in-line with how `--verbose` works. This means that `--quiet` is now accepted with `cargo report`, `cargo help`, and `cargo config`. This also fixes `--quiet` with `cargo clean gc`. This should also help with supporting `--quiet` with the new `cargo owner` subcommands being added in #11879. As for this diff, the help text changes because the `--quiet` flag is changing position (except for the 3 commands mentioned above where it is now added). Fixes #12957
2 parents fa62a0e + 80ffb1d commit 2cbbf6e

File tree

74 files changed

+140
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+140
-83
lines changed

crates/xtask-bump-check/src/xtask.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ pub fn cli() -> clap::Command {
4141
.action(ArgAction::Count)
4242
.global(true),
4343
)
44-
.arg_quiet()
44+
.arg(
45+
flag("quiet", "Do not print cargo log messages")
46+
.short('q')
47+
.global(true),
48+
)
4549
.arg(
4650
opt("color", "Coloring: auto, always, never")
4751
.value_name("WHEN")

src/bin/cargo/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' for more information on a sp
589589
.action(ArgAction::Count)
590590
.global(true),
591591
)
592-
.arg_quiet()
592+
.arg(flag("quiet", "Do not print cargo log messages").short('q').global(true))
593593
.arg(
594594
opt("color", "Coloring: auto, always, never")
595595
.value_name("WHEN")

src/bin/cargo/commands/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Example uses:
8080
.arg_manifest_path_without_unsupported_path_tip()
8181
.arg_package("Package to modify")
8282
.arg_dry_run("Don't actually write the manifest")
83-
.arg_quiet()
83+
.arg_silent_suggestion()
8484
.next_help_heading("Source")
8585
.args([
8686
clap::Arg::new("path")

src/bin/cargo/commands/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn cli() -> Command {
2424
))
2525
.arg_ignore_rust_version()
2626
.arg_message_format()
27-
.arg_quiet()
27+
.arg_silent_suggestion()
2828
.arg_package_spec(
2929
"Package to run benchmarks for",
3030
"Benchmark all packages in the workspace",

src/bin/cargo/commands/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn cli() -> Command {
1010
.arg_ignore_rust_version()
1111
.arg_future_incompat_report()
1212
.arg_message_format()
13-
.arg_quiet()
13+
.arg_silent_suggestion()
1414
.arg_package_spec(
1515
"Package to build (see `cargo help pkgid`)",
1616
"Build all packages in the workspace",

src/bin/cargo/commands/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn cli() -> Command {
1010
.arg_ignore_rust_version()
1111
.arg_future_incompat_report()
1212
.arg_message_format()
13-
.arg_quiet()
13+
.arg_silent_suggestion()
1414
.arg_package_spec(
1515
"Package(s) to check",
1616
"Check all packages in the workspace",

src/bin/cargo/commands/clean.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn cli() -> Command {
1212
subcommand("clean")
1313
.about("Remove artifacts that cargo has generated in the past")
1414
.arg_doc("Whether or not to clean just the documentation directory")
15-
.arg_quiet()
15+
.arg_silent_suggestion()
1616
.arg_package_spec_simple("Package to clean artifacts for")
1717
.arg_release("Whether or not to clean release artifacts")
1818
.arg_profile("Clean artifacts of the specified profile")
@@ -25,8 +25,7 @@ pub fn cli() -> Command {
2525
subcommand("gc")
2626
.about("Clean global caches")
2727
.hide(true)
28-
// FIXME: arg_quiet doesn't work because `config_configure`
29-
// doesn't know about subcommands.
28+
.arg_silent_suggestion()
3029
.arg_dry_run("Display what would be deleted without deleting anything")
3130
// NOTE: Not all of these options may get stabilized. Some of them are
3231
// very low-level details, and may not be something typical users need.

src/bin/cargo/commands/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn cli() -> Command {
1818
.arg(flag("document-private-items", "Document private items"))
1919
.arg_ignore_rust_version()
2020
.arg_message_format()
21-
.arg_quiet()
21+
.arg_silent_suggestion()
2222
.arg_package_spec(
2323
"Package to document",
2424
"Document all packages in the workspace",

src/bin/cargo/commands/fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cargo::ops::FetchOptions;
66
pub fn cli() -> Command {
77
subcommand("fetch")
88
.about("Fetch dependencies of a package from the network")
9-
.arg_quiet()
9+
.arg_silent_suggestion()
1010
.arg_target_triple("Fetch dependencies for the target triple")
1111
.arg_manifest_path()
1212
.after_help(color_print::cstr!(

src/bin/cargo/commands/fix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn cli() -> Command {
2828
))
2929
.arg_ignore_rust_version()
3030
.arg_message_format()
31-
.arg_quiet()
31+
.arg_silent_suggestion()
3232
.arg_package_spec(
3333
"Package(s) to fix",
3434
"Fix all packages in the workspace",

0 commit comments

Comments
 (0)