You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that I can't make an option that only has default value if another option (doesn't takes value) is not set. The closest way is like this:
let matches = App::new("test").arg(Arg::with_name("A").short("A")).arg(Arg::with_name("B").short("B").default_value_if("A",None,"").default_value("A not set")).get_matches();println!("A={} B={}",
matches.value_of("A").unwrap_or("###"),
matches.value_of("B").unwrap_or("###"),
);
I was thinking of passing None to default_value_if might help emulate as if -B is never set (is_present("B")==false). But default_value_if only accepts &str rather than Option.
Describe the solution you'd like
I don't know which would be better. Modifying current signature of default_value_if seems painful, and might bring endless Some to most common cases. So would add default_value_if_not_set be a choice?
Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Please complete the following tasks
Clap Version
2.33.3
Describe your use case
I found that I can't make an option that only has default value if another option (doesn't takes value) is not set. The closest way is like this:
I was thinking of passing
None
todefault_value_if
might help emulate as if-B
is never set (is_present("B")==false
). Butdefault_value_if
only accepts&str
rather thanOption
.Describe the solution you'd like
I don't know which would be better. Modifying current signature of
default_value_if
seems painful, and might bring endlessSome
to most common cases. So would adddefault_value_if_not_set
be a choice?Alternatives, if applicable
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: