mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
Revert "Revert "Added ArgMatcher::is_default_value abstraction""
This reverts commit 5e76e6c568
.
This commit is contained in:
parent
45f281b67e
commit
6b458c602d
2 changed files with 7 additions and 4 deletions
|
@ -126,6 +126,11 @@ impl ArgMatcher {
|
|||
self.0.args.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn is_default_value(&self, arg: &Id) -> bool {
|
||||
self.get(arg)
|
||||
.map_or(false, |a| a.ty == ValueType::DefaultValue)
|
||||
}
|
||||
|
||||
pub(crate) fn inc_occurrence_of(&mut self, arg: &Id, ci: bool) {
|
||||
debug!("ArgMatcher::inc_occurrence_of: arg={:?}", arg);
|
||||
let ma = self.entry(arg).or_insert(MatchedArg::new());
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
output::Usage,
|
||||
parse::{
|
||||
errors::{Error, ErrorKind, Result as ClapResult},
|
||||
ArgMatcher, MatchedArg, ParseState, Parser, ValueType,
|
||||
ArgMatcher, MatchedArg, ParseState, Parser,
|
||||
},
|
||||
util::{ChildGraph, Id},
|
||||
INTERNAL_ERROR_MSG, INVALID_UTF8,
|
||||
|
@ -338,9 +338,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
debug!("Validator::gather_conflicts:iter: id={:?}", name);
|
||||
// if arg is "present" only because it got default value
|
||||
// it doesn't conflict with anything and should be skipped
|
||||
let skip = matcher
|
||||
.get(name)
|
||||
.map_or(false, |a| a.ty == ValueType::DefaultValue);
|
||||
let skip = matcher.is_default_value(name);
|
||||
if skip {
|
||||
debug!("Validator::gather_conflicts:iter: This is default value, skipping.",);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue