Skip to content

Commit

Permalink
Add unsupported short suggestion for --out-dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Oct 4, 2023
1 parent f67b58f commit 7bd0f81
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/bin/cargo/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ pub fn cli() -> Command {
.arg_parallel()
.arg_target_triple("Build for the target triple")
.arg_target_dir()
.arg(
opt(
"out-dir",
"Copy final artifacts to this directory (unstable)",
)
.value_name("PATH")
.help_heading(heading::COMPILATION_OPTIONS),
)
.arg_out_dir()
.arg_build_plan()
.arg_unit_graph()
.arg_timings()
Expand Down
21 changes: 21 additions & 0 deletions src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,27 @@ pub trait CommandExt: Sized {
.help_heading(heading::COMPILATION_OPTIONS),
)
}

fn arg_out_dir(self) -> Self {
let unsupported_short_arg = {
let value_parser = UnknownArgumentValueParser::suggest_arg("--out-dir");
Arg::new("unsupported-short-out-dir-flag")
.help("")
.short('O')
.value_parser(value_parser)
.action(ArgAction::SetTrue)
.hide(true)
};
self._arg(
opt(
"out-dir",
"Copy final artifacts to this directory (unstable)",
)
.value_name("PATH")
.help_heading(heading::COMPILATION_OPTIONS),
)
._arg(unsupported_short_arg)
}
}

impl CommandExt for Command {
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/out_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ fn unsupported_short_out_dir_flag() {
"\
error: unexpected argument '-O' found
tip: a similar argument exists: '--out-dir'
Usage: cargo[EXE] build [OPTIONS]
For more information, try '--help'.
Expand Down

0 comments on commit 7bd0f81

Please sign in to comment.