mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
refactor(args.rs): deprecate mutually_excludes* for conflicts_with* methods
This commit is contained in:
parent
ac161fa3f4
commit
17e3f141aa
1 changed files with 55 additions and 0 deletions
|
@ -367,6 +367,8 @@ impl<'n, 'l, 'h, 'b, 'p, 'r> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
/// by default. Mutually exclusive rules only need to be set for one of the two
|
/// by default. Mutually exclusive rules only need to be set for one of the two
|
||||||
/// arguments, they do not need to be set for each.
|
/// arguments, they do not need to be set for each.
|
||||||
///
|
///
|
||||||
|
/// **NOTE:** This method is deprecated in favor of `conflicts_with()`
|
||||||
|
///
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
@ -391,6 +393,8 @@ impl<'n, 'l, 'h, 'b, 'p, 'r> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
/// by default. Mutually exclusive rules only need to be set for one of the two
|
/// by default. Mutually exclusive rules only need to be set for one of the two
|
||||||
/// arguments, they do not need to be set for each.
|
/// arguments, they do not need to be set for each.
|
||||||
///
|
///
|
||||||
|
/// **NOTE:** This method is deprecated in favor of `conflicts_with_all()`
|
||||||
|
///
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
@ -411,6 +415,57 @@ impl<'n, 'l, 'h, 'b, 'p, 'r> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a mutually exclusive argument by name. I.e. when using this argument,
|
||||||
|
/// the following argument can't be present.
|
||||||
|
///
|
||||||
|
/// **NOTE:** Mutually exclusive rules take precedence over being required
|
||||||
|
/// by default. Mutually exclusive rules only need to be set for one of the two
|
||||||
|
/// arguments, they do not need to be set for each.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// # use clap::{App, Arg};
|
||||||
|
/// # let myprog = App::new("myprog").arg(Arg::with_name("conifg")
|
||||||
|
/// .conflicts_with("debug")
|
||||||
|
/// # ).get_matches();
|
||||||
|
pub fn conflicts_with(mut self, name: &'b str) -> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
|
if let Some(ref mut vec) = self.blacklist {
|
||||||
|
vec.push(name);
|
||||||
|
} else {
|
||||||
|
self.blacklist = Some(vec![name]);
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets mutually exclusive arguments by names. I.e. when using this argument,
|
||||||
|
/// the following argument can't be present.
|
||||||
|
///
|
||||||
|
/// **NOTE:** Mutually exclusive rules take precedence over being required
|
||||||
|
/// by default. Mutually exclusive rules only need to be set for one of the two
|
||||||
|
/// arguments, they do not need to be set for each.
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```no_run
|
||||||
|
/// # use clap::{App, Arg};
|
||||||
|
/// # let myprog = App::new("myprog").arg(Arg::with_name("conifg")
|
||||||
|
/// .conflicts_with_all(
|
||||||
|
/// vec!["debug", "input"])
|
||||||
|
/// # ).get_matches();
|
||||||
|
pub fn conflicts_with_all(mut self, names: Vec<&'b str>) -> Arg<'n, 'l, 'h, 'b, 'p, 'r> {
|
||||||
|
if let Some(ref mut vec) = self.blacklist {
|
||||||
|
for n in names {
|
||||||
|
vec.push(n);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.blacklist = Some(names);
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets an argument by name that is required when this one is presnet I.e. when
|
/// Sets an argument by name that is required when this one is presnet I.e. when
|
||||||
/// using this argument, the following argument *must* be present.
|
/// using this argument, the following argument *must* be present.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue