diff --git a/src/parse/arg_matcher.rs b/src/parse/arg_matcher.rs index 3c7298e1..b0b370ae 100644 --- a/src/parse/arg_matcher.rs +++ b/src/parse/arg_matcher.rs @@ -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()); diff --git a/src/parse/validator.rs b/src/parse/validator.rs index d420bc18..72c5f448 100644 --- a/src/parse/validator.rs +++ b/src/parse/validator.rs @@ -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.",); }