Skip to content

Commit b514ca5

Browse files
committed
Add unsupported short flag suggestion for --exclude flag
Signed-off-by: hi-rustin <[email protected]>
1 parent 718b69c commit b514ca5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,19 @@ pub trait CommandExt: Sized {
6464
all: &'static str,
6565
exclude: &'static str,
6666
) -> Self {
67+
let unsupported_short_arg = {
68+
let value_parser = UnknownArgumentValueParser::suggest_arg("--exclude");
69+
Arg::new("unsupported-short-exclude-flag")
70+
.help("")
71+
.short('x')
72+
.value_parser(value_parser)
73+
.action(ArgAction::SetTrue)
74+
.hide(true)
75+
};
6776
self.arg_package_spec_simple(package)
6877
._arg(flag("workspace", all).help_heading(heading::PACKAGE_SELECTION))
6978
._arg(multi_opt("exclude", "SPEC", exclude).help_heading(heading::PACKAGE_SELECTION))
79+
._arg(unsupported_short_arg)
7080
}
7181

7282
fn arg_package_spec_simple(self, package: &'static str) -> Self {

tests/testsuite/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,6 +4354,8 @@ fn cargo_build_with_unsupported_short_exclude_flag() {
43544354
"\
43554355
error: unexpected argument '-x' found
43564356
4357+
tip: a similar argument exists: '--exclude'
4358+
43574359
Usage: cargo[EXE] build [OPTIONS]
43584360
43594361
For more information, try '--help'.

0 commit comments

Comments
 (0)