Skip to content

Commit 819a836

Browse files
committed
Add unsupported short flag suggestion for --target flag
Signed-off-by: hi-rustin <[email protected]>
1 parent 2f90430 commit 819a836

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
@@ -232,10 +232,20 @@ pub trait CommandExt: Sized {
232232
}
233233

234234
fn arg_target_triple(self, target: &'static str) -> Self {
235+
let unsupported_short_arg = {
236+
let value_parser = UnknownArgumentValueParser::suggest_arg("--target");
237+
Arg::new("unsupported-short-target-flag")
238+
.help("")
239+
.short('t')
240+
.value_parser(value_parser)
241+
.action(ArgAction::SetTrue)
242+
.hide(true)
243+
};
235244
self._arg(
236245
optional_multi_opt("target", "TRIPLE", target)
237246
.help_heading(heading::COMPILATION_OPTIONS),
238247
)
248+
._arg(unsupported_short_arg)
239249
}
240250

241251
fn arg_target_dir(self) -> Self {

tests/testsuite/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4252,6 +4252,8 @@ fn cargo_build_with_unsupported_short_target_flag() {
42524252
"\
42534253
error: unexpected argument '-t' found
42544254
4255+
tip: a similar argument exists: '--target'
4256+
42554257
Usage: cargo[EXE] build [OPTIONS]
42564258
42574259
For more information, try '--help'.

0 commit comments

Comments
 (0)