-
This is similar to #1879, except with the added complexity of values. I basically would like to define a relationship where by If $ cmd # --foo=99 and --bar=99 implied
$ cmd --foo=42 # --bar=42 implied
$ cmd --foo=42 --bar=0 # still possible
$ cmd --bar=0 # --foo=99 because --foo sets default for --bar, not vice versa |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You're probably looking for this one: https://docs.rs/clap/2.33.0/clap/struct.Arg.html#method.overrides_with |
Beta Was this translation helpful? Give feedback.
-
There isn't a current way to do that in let matches = App::new("test")
.arg(Arg::with_name("foo").long("foo").default_value("99"))
.arg(Arg::with_name("bar").long("bar").takes_value(true))
.get_matches();
let foo = matches.value_of("foo").unwrap();
let bar = matches.value_of("bar").unwrap_or(foo); Edit: simplified |
Beta Was this translation helpful? Give feedback.
There isn't a current way to do that in
clap
code, however doing so in consumer code is fairly easy:Edit: simplified