Skip to content

Commit 5d8009a

Browse files
committed
Better suggestion for unsupported silent flag
1 parent 61648f5 commit 5d8009a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/bin/cargo/commands/vendor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn cli() -> Command {
3636
.arg(unsupported("relative-path"))
3737
.arg(unsupported("only-git-deps"))
3838
.arg(unsupported("disallow-duplicates"))
39-
.arg_quiet()
39+
.arg_quiet_without_unknown_silent_arg_tip()
4040
.arg_manifest_path()
4141
.after_help(color_print::cstr!(
4242
"Run `<cyan,bold>cargo help vendor</>` for more detailed information.\n"

src/cargo/util/command_prelude.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,18 @@ pub trait CommandExt: Sized {
331331
}
332332

333333
fn arg_quiet(self) -> Self {
334+
let unsupported_silent_arg = {
335+
let value_parser = UnknownArgumentValueParser::suggest_arg("--quiet");
336+
flag("silent", "")
337+
.short('s')
338+
.value_parser(value_parser)
339+
.hide(true)
340+
};
341+
self._arg(flag("quiet", "Do not print cargo log messages").short('q'))
342+
._arg(unsupported_silent_arg)
343+
}
344+
345+
fn arg_quiet_without_unknown_silent_arg_tip(self) -> Self {
334346
self._arg(flag("quiet", "Do not print cargo log messages").short('q'))
335347
}
336348

tests/testsuite/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ fn unsupported_silent_arg() {
4646
p.cargo("run -s")
4747
.with_stderr(
4848
"\
49-
error: unexpected argument '-s' found
49+
error: unexpected argument '--silent' found
5050
51-
tip: to pass '-s' as a value, use '-- -s'
51+
tip: a similar argument exists: '--quiet'
5252
5353
Usage: cargo run [OPTIONS] [args]...
5454
@@ -63,7 +63,7 @@ For more information, try '--help'.
6363
"\
6464
error: unexpected argument '--silent' found
6565
66-
tip: to pass '--silent' as a value, use '-- --silent'
66+
tip: a similar argument exists: '--quiet'
6767
6868
Usage: cargo run [OPTIONS] [args]...
6969

0 commit comments

Comments
 (0)