mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +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()
|
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) {
|
pub(crate) fn inc_occurrence_of(&mut self, arg: &Id, ci: bool) {
|
||||||
debug!("ArgMatcher::inc_occurrence_of: arg={:?}", arg);
|
debug!("ArgMatcher::inc_occurrence_of: arg={:?}", arg);
|
||||||
let ma = self.entry(arg).or_insert(MatchedArg::new());
|
let ma = self.entry(arg).or_insert(MatchedArg::new());
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
output::Usage,
|
output::Usage,
|
||||||
parse::{
|
parse::{
|
||||||
errors::{Error, ErrorKind, Result as ClapResult},
|
errors::{Error, ErrorKind, Result as ClapResult},
|
||||||
ArgMatcher, MatchedArg, ParseState, Parser, ValueType,
|
ArgMatcher, MatchedArg, ParseState, Parser,
|
||||||
},
|
},
|
||||||
util::{ChildGraph, Id},
|
util::{ChildGraph, Id},
|
||||||
INTERNAL_ERROR_MSG, INVALID_UTF8,
|
INTERNAL_ERROR_MSG, INVALID_UTF8,
|
||||||
|
@ -338,9 +338,7 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
||||||
debug!("Validator::gather_conflicts:iter: id={:?}", name);
|
debug!("Validator::gather_conflicts:iter: id={:?}", name);
|
||||||
// if arg is "present" only because it got default value
|
// if arg is "present" only because it got default value
|
||||||
// it doesn't conflict with anything and should be skipped
|
// it doesn't conflict with anything and should be skipped
|
||||||
let skip = matcher
|
let skip = matcher.is_default_value(name);
|
||||||
.get(name)
|
|
||||||
.map_or(false, |a| a.ty == ValueType::DefaultValue);
|
|
||||||
if skip {
|
if skip {
|
||||||
debug!("Validator::gather_conflicts:iter: This is default value, skipping.",);
|
debug!("Validator::gather_conflicts:iter: This is default value, skipping.",);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue