Skip to content

Commit

Permalink
Add unsupported short flag suggestion for --exclude flag
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <[email protected]>
  • Loading branch information
Rustin170506 committed Oct 11, 2023
1 parent 718b69c commit b514ca5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,19 @@ pub trait CommandExt: Sized {
all: &'static str,
exclude: &'static str,
) -> Self {
let unsupported_short_arg = {
let value_parser = UnknownArgumentValueParser::suggest_arg("--exclude");
Arg::new("unsupported-short-exclude-flag")
.help("")
.short('x')
.value_parser(value_parser)
.action(ArgAction::SetTrue)
.hide(true)
};
self.arg_package_spec_simple(package)
._arg(flag("workspace", all).help_heading(heading::PACKAGE_SELECTION))
._arg(multi_opt("exclude", "SPEC", exclude).help_heading(heading::PACKAGE_SELECTION))
._arg(unsupported_short_arg)
}

fn arg_package_spec_simple(self, package: &'static str) -> Self {
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4354,6 +4354,8 @@ fn cargo_build_with_unsupported_short_exclude_flag() {
"\
error: unexpected argument '-x' found
tip: a similar argument exists: '--exclude'
Usage: cargo[EXE] build [OPTIONS]
For more information, try '--help'.
Expand Down

0 comments on commit b514ca5

Please sign in to comment.