mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
refactor(parser): Be consistent on terms
This commit is contained in:
parent
c7aa471deb
commit
211d36efad
2 changed files with 7 additions and 7 deletions
|
@ -126,11 +126,11 @@ impl ArgMatcher {
|
|||
self.0.args.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn inc_occurrence_of(&mut self, arg: &Id, ci: bool) {
|
||||
pub(crate) fn inc_occurrence_of(&mut self, arg: &Id, ignore_case: bool) {
|
||||
debug!("ArgMatcher::inc_occurrence_of: arg={:?}", arg);
|
||||
let ma = self.entry(arg).or_insert(MatchedArg::new());
|
||||
ma.set_ty(ValueType::CommandLine);
|
||||
ma.set_case_insensitive(ci);
|
||||
ma.set_ignore_case(ignore_case);
|
||||
ma.occurs += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub(crate) struct MatchedArg {
|
|||
pub(crate) ty: ValueType,
|
||||
indices: Vec<usize>,
|
||||
vals: Vec<Vec<OsString>>,
|
||||
case_insensitive: bool,
|
||||
ignore_case: bool,
|
||||
}
|
||||
|
||||
impl Default for MatchedArg {
|
||||
|
@ -40,7 +40,7 @@ impl MatchedArg {
|
|||
ty: ValueType::Unknown,
|
||||
indices: Vec::new(),
|
||||
vals: Vec::new(),
|
||||
case_insensitive: false,
|
||||
ignore_case: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ impl MatchedArg {
|
|||
|
||||
pub(crate) fn contains_val(&self, val: &str) -> bool {
|
||||
self.vals_flatten().any(|v| {
|
||||
if self.case_insensitive {
|
||||
if self.ignore_case {
|
||||
// If `v` isn't utf8, it can't match `val`, so `OsStr::to_str` should be fine
|
||||
v.to_str().map_or(false, |v| eq_ignore_case(v, val))
|
||||
} else {
|
||||
|
@ -140,8 +140,8 @@ impl MatchedArg {
|
|||
self.ty = ty;
|
||||
}
|
||||
|
||||
pub(crate) fn set_case_insensitive(&mut self, ci: bool) {
|
||||
self.case_insensitive = ci;
|
||||
pub(crate) fn set_ignore_case(&mut self, yes: bool) {
|
||||
self.ignore_case = yes;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue