mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 21:11:44 +00:00
Auto merge of #12723 - hi-rustin:rustin-patch-silent, r=weihanglo
Add better suggestion for the unsupported silent flag
This commit is contained in:
commit
e3acdd321f
|
@ -36,7 +36,7 @@ pub fn cli() -> Command {
|
|||
.arg(unsupported("relative-path"))
|
||||
.arg(unsupported("only-git-deps"))
|
||||
.arg(unsupported("disallow-duplicates"))
|
||||
.arg_quiet()
|
||||
.arg_quiet_without_unknown_silent_arg_tip()
|
||||
.arg_manifest_path()
|
||||
.after_help(color_print::cstr!(
|
||||
"Run `<cyan,bold>cargo help vendor</>` for more detailed information.\n"
|
||||
|
|
|
@ -331,6 +331,18 @@ pub trait CommandExt: Sized {
|
|||
}
|
||||
|
||||
fn arg_quiet(self) -> Self {
|
||||
let unsupported_silent_arg = {
|
||||
let value_parser = UnknownArgumentValueParser::suggest_arg("--quiet");
|
||||
flag("silent", "")
|
||||
.short('s')
|
||||
.value_parser(value_parser)
|
||||
.hide(true)
|
||||
};
|
||||
self._arg(flag("quiet", "Do not print cargo log messages").short('q'))
|
||||
._arg(unsupported_silent_arg)
|
||||
}
|
||||
|
||||
fn arg_quiet_without_unknown_silent_arg_tip(self) -> Self {
|
||||
self._arg(flag("quiet", "Do not print cargo log messages").short('q'))
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,43 @@ fn quiet_arg() {
|
|||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn unsupported_silent_arg() {
|
||||
let p = project()
|
||||
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
|
||||
.build();
|
||||
|
||||
p.cargo("run -s")
|
||||
.with_stderr(
|
||||
"\
|
||||
error: unexpected argument '--silent' found
|
||||
|
||||
tip: a similar argument exists: '--quiet'
|
||||
|
||||
Usage: cargo[EXE] run [OPTIONS] [args]...
|
||||
|
||||
For more information, try '--help'.
|
||||
",
|
||||
)
|
||||
.with_status(1)
|
||||
.run();
|
||||
|
||||
p.cargo("run --silent")
|
||||
.with_stderr(
|
||||
"\
|
||||
error: unexpected argument '--silent' found
|
||||
|
||||
tip: a similar argument exists: '--quiet'
|
||||
|
||||
Usage: cargo[EXE] run [OPTIONS] [args]...
|
||||
|
||||
For more information, try '--help'.
|
||||
",
|
||||
)
|
||||
.with_status(1)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn quiet_arg_and_verbose_arg() {
|
||||
let p = project()
|
||||
|
|
Loading…
Reference in a new issue