Add unsupported short flag suggestion for --exclude flag

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2023-10-11 09:41:05 +08:00
parent 718b69ce19
commit b514ca5e24
2 changed files with 12 additions and 0 deletions

View File

@ -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 {

View File

@ -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'.