mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 15:27:16 +00:00
refactor(parser): Fix naming of ty
This commit is contained in:
parent
bc6da813bd
commit
f296c5ca78
2 changed files with 17 additions and 17 deletions
|
@ -131,7 +131,7 @@ impl ArgMatcher {
|
|||
let id = &arg.id;
|
||||
debug!("ArgMatcher::inc_occurrence_of_arg: id={:?}", id);
|
||||
let ma = self.entry(id).or_insert(MatchedArg::new());
|
||||
ma.update_ty(ValueSource::CommandLine);
|
||||
ma.set_source(ValueSource::CommandLine);
|
||||
ma.set_ignore_case(arg.is_ignore_case_set());
|
||||
ma.inc_occurrences();
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl ArgMatcher {
|
|||
pub(crate) fn inc_occurrence_of_group(&mut self, id: &Id) {
|
||||
debug!("ArgMatcher::inc_occurrence_of_group: id={:?}", id);
|
||||
let ma = self.entry(id).or_insert(MatchedArg::new());
|
||||
ma.update_ty(ValueSource::CommandLine);
|
||||
ma.set_source(ValueSource::CommandLine);
|
||||
ma.inc_occurrences();
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ impl ArgMatcher {
|
|||
let id = &Id::empty_hash();
|
||||
debug!("ArgMatcher::inc_occurrence_of_external: id={:?}", id,);
|
||||
let ma = self.entry(id).or_insert(MatchedArg::new());
|
||||
ma.update_ty(ValueSource::CommandLine);
|
||||
ma.set_source(ValueSource::CommandLine);
|
||||
ma.inc_occurrences();
|
||||
}
|
||||
|
||||
|
@ -172,13 +172,13 @@ impl ArgMatcher {
|
|||
// specific circumstances, like only add one occurrence for flag
|
||||
// when we met: `--flag=one,two`).
|
||||
let ma = self.entry(arg).or_default();
|
||||
ma.update_ty(ty);
|
||||
ma.set_source(ty);
|
||||
ma.push_val(val, raw_val);
|
||||
}
|
||||
|
||||
fn append_val_to(&mut self, arg: &Id, val: AnyValue, raw_val: OsString, ty: ValueSource) {
|
||||
let ma = self.entry(arg).or_default();
|
||||
ma.update_ty(ty);
|
||||
ma.set_source(ty);
|
||||
ma.append_val(val, raw_val);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ impl ArgMatcher {
|
|||
|
||||
pub(crate) fn add_index_to(&mut self, arg: &Id, idx: usize, ty: ValueSource) {
|
||||
let ma = self.entry(arg).or_default();
|
||||
ma.update_ty(ty);
|
||||
ma.set_source(ty);
|
||||
ma.push_index(idx);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use crate::INTERNAL_ERROR_MSG;
|
|||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct MatchedArg {
|
||||
occurs: u64,
|
||||
ty: Option<ValueSource>,
|
||||
source: Option<ValueSource>,
|
||||
indices: Vec<usize>,
|
||||
vals: Vec<Vec<AnyValue>>,
|
||||
raw_vals: Vec<Vec<OsString>>,
|
||||
|
@ -25,7 +25,7 @@ impl MatchedArg {
|
|||
pub(crate) fn new() -> Self {
|
||||
MatchedArg {
|
||||
occurs: 0,
|
||||
ty: None,
|
||||
source: None,
|
||||
indices: Vec::new(),
|
||||
vals: Vec::new(),
|
||||
raw_vals: Vec::new(),
|
||||
|
@ -118,7 +118,7 @@ impl MatchedArg {
|
|||
}
|
||||
|
||||
pub(crate) fn check_explicit(&self, predicate: ArgPredicate) -> bool {
|
||||
if self.ty == Some(ValueSource::DefaultValue) {
|
||||
if self.source == Some(ValueSource::DefaultValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -136,14 +136,14 @@ impl MatchedArg {
|
|||
}
|
||||
|
||||
pub(crate) fn source(&self) -> Option<ValueSource> {
|
||||
self.ty
|
||||
self.source
|
||||
}
|
||||
|
||||
pub(crate) fn update_ty(&mut self, ty: ValueSource) {
|
||||
if let Some(existing) = self.ty {
|
||||
self.ty = Some(existing.max(ty));
|
||||
pub(crate) fn set_source(&mut self, source: ValueSource) {
|
||||
if let Some(existing) = self.source {
|
||||
self.source = Some(existing.max(source));
|
||||
} else {
|
||||
self.ty = Some(ty)
|
||||
self.source = Some(source)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ impl PartialEq for MatchedArg {
|
|||
fn eq(&self, other: &MatchedArg) -> bool {
|
||||
let MatchedArg {
|
||||
occurs: self_occurs,
|
||||
ty: self_ty,
|
||||
source: self_source,
|
||||
indices: self_indices,
|
||||
vals: _,
|
||||
raw_vals: self_raw_vals,
|
||||
|
@ -170,14 +170,14 @@ impl PartialEq for MatchedArg {
|
|||
} = self;
|
||||
let MatchedArg {
|
||||
occurs: other_occurs,
|
||||
ty: other_ty,
|
||||
source: other_source,
|
||||
indices: other_indices,
|
||||
vals: _,
|
||||
raw_vals: other_raw_vals,
|
||||
ignore_case: other_ignore_case,
|
||||
} = other;
|
||||
self_occurs == other_occurs
|
||||
&& self_ty == other_ty
|
||||
&& self_source == other_source
|
||||
&& self_indices == other_indices
|
||||
&& self_raw_vals == other_raw_vals
|
||||
&& self_ignore_case == other_ignore_case
|
||||
|
|
Loading…
Add table
Reference in a new issue