diff --git a/src/parse/arg_matcher.rs b/src/parse/arg_matcher.rs index 1d2ce6ca..58a94059 100644 --- a/src/parse/arg_matcher.rs +++ b/src/parse/arg_matcher.rs @@ -176,8 +176,11 @@ impl ArgMatcher { ma.push_index(idx); } - pub(crate) fn arg_have_val(&mut self, arg: &Id) -> bool { - matches!(self.entry(arg), Entry::Occupied(_)) + pub(crate) fn has_val_groups(&mut self, arg: &Id) -> bool { + match self.entry(arg) { + Entry::Occupied(e) => e.get().has_val_groups(), + Entry::Vacant(_) => false, + } } pub(crate) fn needs_more_vals(&self, o: &Arg) -> bool { diff --git a/src/parse/matches/matched_arg.rs b/src/parse/matches/matched_arg.rs index c2d86f44..90752fb4 100644 --- a/src/parse/matches/matched_arg.rs +++ b/src/parse/matches/matched_arg.rs @@ -81,6 +81,10 @@ impl MatchedArg { self.vals.iter().flatten().count() == 0 } + pub(crate) fn has_val_groups(&self) -> bool { + !self.vals.is_empty() + } + // Will be used later #[allow(dead_code)] pub(crate) fn remove_vals(&mut self, len: usize) { diff --git a/src/parse/parser.rs b/src/parse/parser.rs index dd4953c6..14528f2e 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -594,7 +594,7 @@ impl<'help, 'app> Parser<'help, 'app> { // Creating new value group rather than appending when the arg // doesn't have any value. This behaviour is right because // positional arguments are always present continuously. - let append = self.arg_have_val(matcher, p); + let append = self.has_val_groups(matcher, p); self.add_val_to_arg( p, &arg_os, @@ -1463,8 +1463,8 @@ impl<'help, 'app> Parser<'help, 'app> { matcher.add_index_to(&arg.id, self.cur_idx.get(), ty); } - fn arg_have_val(&self, matcher: &mut ArgMatcher, arg: &Arg<'help>) -> bool { - matcher.arg_have_val(&arg.id) + fn has_val_groups(&self, matcher: &mut ArgMatcher, arg: &Arg<'help>) -> bool { + matcher.has_val_groups(&arg.id) } fn parse_flag(&self, flag: &Arg<'help>, matcher: &mut ArgMatcher) -> ParseResult {