Skip to content

Commit

Permalink
refactor(parser): Centralize group handling
Browse files Browse the repository at this point in the history
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
  • Loading branch information
epage committed Oct 12, 2022
1 parent 0f30ac7 commit e704adb
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down Expand Up @@ -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()),
);
}
}
}
Expand Down

0 comments on commit e704adb

Please sign in to comment.