Skip to content

Commit

Permalink
refactor(parser): Reduce code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Oct 12, 2022
1 parent e5a7a65 commit 43c1fa3
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/parser/arg_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,11 @@ impl ArgMatcher {
}

pub(crate) fn start_occurrence_of_arg(&mut self, arg: &Arg) {
let id = arg.get_id().clone();
debug!("ArgMatcher::start_occurrence_of_arg: id={:?}", id);
let ma = self.entry(id).or_insert(MatchedArg::new_arg(arg));
debug_assert_eq!(ma.type_id(), Some(arg.get_value_parser().type_id()));
ma.set_source(ValueSource::CommandLine);
ma.new_val_group();
self.start_custom_arg(arg, ValueSource::CommandLine);
}

pub(crate) fn start_occurrence_of_group(&mut self, id: Id) {
debug!("ArgMatcher::start_occurrence_of_group: id={:?}", id);
let ma = self.entry(id).or_insert(MatchedArg::new_group());
debug_assert_eq!(ma.type_id(), None);
ma.set_source(ValueSource::CommandLine);
ma.new_val_group();
self.start_custom_group(id, ValueSource::CommandLine);
}

pub(crate) fn start_occurrence_of_external(&mut self, cmd: &crate::Command) {
Expand Down

0 comments on commit 43c1fa3

Please sign in to comment.