mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +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 {
|
||||
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 {
|
||||
|
@ -1389,10 +1389,9 @@ fn both_index_and_registry() {
|
||||
p.cargo(cmd)
|
||||
.arg("--registry=foo")
|
||||
.arg("--index=foo")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"[ERROR] both `--index` and `--registry` \
|
||||
should not be set at the same time",
|
||||
.with_status(1)
|
||||
.with_stderr_contains(
|
||||
"error: the argument '--registry <REGISTRY>' cannot be used with '--index <INDEX>'",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user