mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
refactor: Clarify MatchArg::all_val_groups_empty
This commit is contained in:
parent
a0ab35d678
commit
2d1dfae318
3 changed files with 4 additions and 4 deletions
|
@ -77,7 +77,7 @@ impl MatchedArg {
|
|||
self.vals.last().map(|x| x.len()).unwrap_or(0)
|
||||
}
|
||||
|
||||
pub(crate) fn is_vals_empty(&self) -> bool {
|
||||
pub(crate) fn all_val_groups_empty(&self) -> bool {
|
||||
self.vals.iter().flatten().count() == 0
|
||||
}
|
||||
|
||||
|
|
|
@ -1638,7 +1638,7 @@ impl<'help, 'app> Parser<'help, 'app> {
|
|||
arg.name
|
||||
);
|
||||
match matcher.get(&arg.id) {
|
||||
Some(ma) if ma.is_vals_empty() => {
|
||||
Some(ma) if ma.all_val_groups_empty() => {
|
||||
debug!(
|
||||
"Parser::add_value:iter:{}: has no user defined vals",
|
||||
arg.name
|
||||
|
|
|
@ -42,7 +42,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
let o = &self.p.app[&a];
|
||||
reqs_validated = true;
|
||||
let should_err = if let Some(v) = matcher.0.args.get(&o.id) {
|
||||
v.is_vals_empty() && !(o.min_vals.is_some() && o.min_vals.unwrap() == 0)
|
||||
v.all_val_groups_empty() && !(o.min_vals.is_some() && o.min_vals.unwrap() == 0)
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
@ -396,7 +396,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
};
|
||||
// Issue 665 (https://github.com/clap-rs/clap/issues/665)
|
||||
// Issue 1105 (https://github.com/clap-rs/clap/issues/1105)
|
||||
if a.is_set(ArgSettings::TakesValue) && !min_vals_zero && ma.is_vals_empty() {
|
||||
if a.is_set(ArgSettings::TakesValue) && !min_vals_zero && ma.all_val_groups_empty() {
|
||||
return Err(Error::empty_value(
|
||||
self.p.app,
|
||||
a,
|
||||
|
|
Loading…
Reference in a new issue