mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 06:12:40 +00:00
feat(builder): Infer takes_vaue from action
This commit is contained in:
parent
91480de6d2
commit
e53dd937be
2 changed files with 7 additions and 2 deletions
|
@ -35,7 +35,6 @@ pub enum ArgAction {
|
|||
/// .arg(
|
||||
/// Arg::new("flag")
|
||||
/// .long("flag")
|
||||
/// .takes_value(true)
|
||||
/// .action(clap::builder::ArgAction::StoreValue)
|
||||
/// );
|
||||
///
|
||||
|
|
|
@ -1014,7 +1014,6 @@ impl<'help> Arg<'help> {
|
|||
/// .arg(
|
||||
/// Arg::new("flag")
|
||||
/// .long("flag")
|
||||
/// .takes_value(true)
|
||||
/// .action(clap::builder::ArgAction::StoreValue)
|
||||
/// );
|
||||
///
|
||||
|
@ -4892,6 +4891,13 @@ impl<'help> Arg<'help> {
|
|||
if self.is_positional() {
|
||||
self.settings.set(ArgSettings::TakesValue);
|
||||
}
|
||||
if let Some(action) = self.action.as_ref() {
|
||||
if action.takes_value() {
|
||||
self.settings.set(ArgSettings::TakesValue);
|
||||
} else {
|
||||
self.settings.unset(ArgSettings::TakesValue);
|
||||
}
|
||||
}
|
||||
|
||||
if self.value_parser.is_none() {
|
||||
if self.is_allow_invalid_utf8_set() {
|
||||
|
|
Loading…
Reference in a new issue