Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support term.quiet configuration #10152

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,20 +909,19 @@ impl Config {

let color = color.or_else(|| term.color.as_deref());

let verbosity = match (verbose, term.verbose, quiet) {
(true, _, false) | (_, Some(true), false) => Verbosity::Verbose,

// Command line takes precedence over configuration, so ignore the
// configuration..
(false, _, true) => Verbosity::Quiet,

// Can't pass both at the same time on the command line regardless
// of configuration.
(true, _, true) => {
bail!("cannot set both --verbose and --quiet");
}

(false, _, false) => Verbosity::Normal,
// The command line takes precedence over configuration.
let verbosity = match (verbose, quiet) {
(true, true) => bail!("cannot set both --verbose and --quiet"),
(true, false) => Verbosity::Verbose,
(false, true) => Verbosity::Quiet,
(false, false) => match (term.verbose, term.quiet) {
(Some(true), Some(true)) => {
bail!("cannot set both `term.verbose` and `term.quiet`")
}
(Some(true), Some(false)) => Verbosity::Verbose,
(Some(false), Some(true)) => Verbosity::Quiet,
_ => Verbosity::Normal,
},
};

let cli_target_dir = target_dir.as_ref().map(|dir| Filesystem::new(dir.clone()));
Expand Down Expand Up @@ -2127,6 +2126,7 @@ pub struct CargoBuildConfig {
#[derive(Deserialize, Default)]
struct TermConfig {
verbose: Option<bool>,
quiet: Option<bool>,
color: Option<String>,
#[serde(default)]
#[serde(deserialize_with = "progress_or_string")]
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-bench.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-check.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-fetch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-fix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-generate-lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-locate-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-owner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-pkgid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-publish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-rustc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-rustdoc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-uninstall.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-update.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-verify-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo-yank.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
4 changes: 3 additions & 1 deletion src/doc/man/generated_txt/cargo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ OPTIONS
value <https://doc.rust-lang.org/cargo/reference/config.html>.

-q, --quiet
Do not print cargo log messages.
Do not print cargo log messages. May also be specified with the
term.quiet config value
<https://doc.rust-lang.org/cargo/reference/config.html>.

--color when
Control when colored output is used. Valid values:
Expand Down
2 changes: 2 additions & 0 deletions src/doc/man/includes/options-display.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ May also be specified with the `term.verbose`

{{#option "`-q`" "`--quiet`"}}
Do not print cargo log messages.
May also be specified with the `term.quiet`
[config value](../reference/config.html).
{{/option}}

{{#option "`--color` _when_"}}
Expand Down
4 changes: 3 additions & 1 deletion src/doc/src/commands/cargo-bench.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ May also be specified with the <code>term.verbose</code>

<dt class="option-term" id="option-cargo-bench--q"><a class="option-anchor" href="#option-cargo-bench--q"></a><code>-q</code></dt>
<dt class="option-term" id="option-cargo-bench---quiet"><a class="option-anchor" href="#option-cargo-bench---quiet"></a><code>--quiet</code></dt>
<dd class="option-desc">Do not print cargo log messages.</dd>
<dd class="option-desc">Do not print cargo log messages.
May also be specified with the <code>term.quiet</code>
<a href="../reference/config.html">config value</a>.</dd>


<dt class="option-term" id="option-cargo-bench---color"><a class="option-anchor" href="#option-cargo-bench---color"></a><code>--color</code> <em>when</em></dt>
Expand Down
Loading