mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(cli): Error trailing args rather than ignore
This warning has been in for a sufficient time, requires a hack from clap to avoid all argument ID validation, and allows users to run the wrong command (imagine `cargo -- publish --dry-run`). See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Cargo.20ignoring.20arguments.20with.20.60cargo.20--.20check.20--ignored.60
This commit is contained in:
parent
8dea81918b
commit
8f8a79a5a4
@ -242,11 +242,15 @@ fn expand_aliases(
|
|||||||
(Some(_), None) => {
|
(Some(_), None) => {
|
||||||
// Command is built-in and is not conflicting with alias, but contains ignored values.
|
// Command is built-in and is not conflicting with alias, but contains ignored values.
|
||||||
if let Some(mut values) = args.get_many::<String>("") {
|
if let Some(mut values) = args.get_many::<String>("") {
|
||||||
config.shell().warn(format!(
|
return Err(anyhow::format_err!(
|
||||||
"trailing arguments after built-in command `{}` are ignored: `{}`",
|
"\
|
||||||
|
trailing arguments after built-in command `{}` are unsupported: `{}`
|
||||||
|
|
||||||
|
To pass the arguments to the subcommand, remove `--`",
|
||||||
cmd,
|
cmd,
|
||||||
values.join(" "),
|
values.join(" "),
|
||||||
))?;
|
)
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(None, None) => {}
|
(None, None) => {}
|
||||||
|
@ -324,11 +324,12 @@ fn weird_check() {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
p.cargo("-- check --invalid_argument -some-other-argument")
|
p.cargo("-- check --invalid_argument -some-other-argument")
|
||||||
|
.with_status(101)
|
||||||
.with_stderr(
|
.with_stderr(
|
||||||
"\
|
"\
|
||||||
[WARNING] trailing arguments after built-in command `check` are ignored: `--invalid_argument -some-other-argument`
|
[ERROR] trailing arguments after built-in command `check` are unsupported: `--invalid_argument -some-other-argument`
|
||||||
[CHECKING] foo v0.5.0 ([..])
|
|
||||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
To pass the arguments to the subcommand, remove `--`
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user