diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 01686c8e79e..25176cb22d1 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -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 { diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 405922412d8..fdb8a4d7a4c 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -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'.