mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +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(
|
||||||
/// Arg::new("flag")
|
/// Arg::new("flag")
|
||||||
/// .long("flag")
|
/// .long("flag")
|
||||||
/// .takes_value(true)
|
|
||||||
/// .action(clap::builder::ArgAction::StoreValue)
|
/// .action(clap::builder::ArgAction::StoreValue)
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
|
|
|
@ -1014,7 +1014,6 @@ impl<'help> Arg<'help> {
|
||||||
/// .arg(
|
/// .arg(
|
||||||
/// Arg::new("flag")
|
/// Arg::new("flag")
|
||||||
/// .long("flag")
|
/// .long("flag")
|
||||||
/// .takes_value(true)
|
|
||||||
/// .action(clap::builder::ArgAction::StoreValue)
|
/// .action(clap::builder::ArgAction::StoreValue)
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
|
@ -4892,6 +4891,13 @@ impl<'help> Arg<'help> {
|
||||||
if self.is_positional() {
|
if self.is_positional() {
|
||||||
self.settings.set(ArgSettings::TakesValue);
|
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.value_parser.is_none() {
|
||||||
if self.is_allow_invalid_utf8_set() {
|
if self.is_allow_invalid_utf8_set() {
|
||||||
|
|
Loading…
Reference in a new issue