From 43c1fa30d0c093cf03553c5ad818137e28a4de4a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 12 Oct 2022 07:26:30 -0500 Subject: [PATCH] refactor(parser): Reduce code duplication --- src/parser/arg_matcher.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/parser/arg_matcher.rs b/src/parser/arg_matcher.rs index 65102c2bc6f..1b04087f0d8 100644 --- a/src/parser/arg_matcher.rs +++ b/src/parser/arg_matcher.rs @@ -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) {