From e704adb4ff55d26190b7d1b524ec899083e7f42d Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 12 Oct 2022 07:34:19 -0500 Subject: [PATCH] refactor(parser): Centralize group handling Since groups are only associated with the occurrence, we can move the assigning of it to the occurrence start. This will help centralize other checks --- src/parser/parser.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/parser/parser.rs b/src/parser/parser.rs index 4cbc5c32899..62471334e50 100644 --- a/src/parser/parser.rs +++ b/src/parser/parser.rs @@ -1078,15 +1078,6 @@ impl<'cmd> Parser<'cmd> { matcher.add_index_to(arg.get_id(), self.cur_idx.get()); } - // Increment or create the group "args" - for group in self.cmd.groups_for_arg(arg.get_id()) { - matcher.add_val_to( - &group, - AnyValue::new(arg.get_id().clone()), - OsString::from(arg.get_id().as_str()), - ); - } - Ok(()) } @@ -1500,7 +1491,12 @@ impl<'cmd> Parser<'cmd> { } matcher.start_custom_arg(arg, source); for group in self.cmd.groups_for_arg(arg.get_id()) { - matcher.start_custom_group(group, source); + matcher.start_custom_group(group.clone(), source); + matcher.add_val_to( + &group, + AnyValue::new(arg.get_id().clone()), + OsString::from(arg.get_id().as_str()), + ); } } }