mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
refactor: --registry
always conflicts with --index
Move the validation upfront to clap
This commit is contained in:
parent
1f172e4b76
commit
e57ce13da8
@ -291,7 +291,12 @@ pub trait CommandExt: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn arg_index(self, help: &'static str) -> Self {
|
fn arg_index(self, help: &'static str) -> Self {
|
||||||
self._arg(opt("index", help).value_name("INDEX"))
|
// Always conflicts with `--registry`.
|
||||||
|
self._arg(
|
||||||
|
opt("index", help)
|
||||||
|
.value_name("INDEX")
|
||||||
|
.conflicts_with("registry"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_dry_run(self, dry_run: &'static str) -> Self {
|
fn arg_dry_run(self, dry_run: &'static str) -> Self {
|
||||||
|
@ -1389,10 +1389,9 @@ fn both_index_and_registry() {
|
|||||||
p.cargo(cmd)
|
p.cargo(cmd)
|
||||||
.arg("--registry=foo")
|
.arg("--registry=foo")
|
||||||
.arg("--index=foo")
|
.arg("--index=foo")
|
||||||
.with_status(101)
|
.with_status(1)
|
||||||
.with_stderr(
|
.with_stderr_contains(
|
||||||
"[ERROR] both `--index` and `--registry` \
|
"error: the argument '--registry <REGISTRY>' cannot be used with '--index <INDEX>'",
|
||||||
should not be set at the same time",
|
|
||||||
)
|
)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user