Skip to content

Commit 8ae23fd

Browse files
committed
Better suggestion for unsupported silent flag
1 parent 61648f5 commit 8ae23fd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/cargo/util/command_prelude.rs

+8
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,15 @@ 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+
};
334341
self._arg(flag("quiet", "Do not print cargo log messages").short('q'))
342+
._arg(unsupported_silent_arg)
335343
}
336344

337345
fn arg_timings(self) -> Self {

tests/testsuite/run.rs

+3-3
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)