Skip to content

Commit

Permalink
feat(builder): Infer takes_vaue from action
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jun 1, 2022
1 parent 91480de commit e53dd93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/builder/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub enum ArgAction {
/// .arg(
/// Arg::new("flag")
/// .long("flag")
/// .takes_value(true)
/// .action(clap::builder::ArgAction::StoreValue)
/// );
///
Expand Down
8 changes: 7 additions & 1 deletion src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,6 @@ impl<'help> Arg<'help> {
/// .arg(
/// Arg::new("flag")
/// .long("flag")
/// .takes_value(true)
/// .action(clap::builder::ArgAction::StoreValue)
/// );
///
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit e53dd93

Please sign in to comment.