Skip to content

Commit

Permalink
Better suggestion for unsupported silent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Sep 26, 2023
1 parent 61648f5 commit 54ba72b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,15 @@ 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_timings(self) -> Self {
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ fn unsupported_silent_arg() {
p.cargo("run -s")
.with_stderr(
"\
error: unexpected argument '-s' found
error: unexpected argument '--silent' found
tip: to pass '-s' as a value, use '-- -s'
tip: there is no `--silent` flag, use `--quiet` to suppress output
Usage: cargo run [OPTIONS] [args]...
Expand All @@ -63,7 +63,7 @@ For more information, try '--help'.
"\
error: unexpected argument '--silent' found
tip: to pass '--silent' as a value, use '-- --silent'
tip: there is no `--silent` flag, use `--quiet` to suppress output
Usage: cargo run [OPTIONS] [args]...
Expand Down

0 comments on commit 54ba72b

Please sign in to comment.