Skip to content

Commit

Permalink
Merge pull request #3712 from epage/assert
Browse files Browse the repository at this point in the history
fix(assert): Make sure group members exist before using them
  • Loading branch information
epage committed May 10, 2022
2 parents a57a411 + 7c1f912 commit 9713cd9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/build/debug_asserts.rs
Expand Up @@ -301,6 +301,17 @@ pub(crate) fn assert_app(cmd: &Command) {
group.name,
);

for arg in &group.args {
// Args listed inside groups should exist
assert!(
cmd.get_arguments().any(|x| x.id == *arg),
"Command {}: Argument group '{}' contains non-existent argument '{:?}'",
cmd.get_name(),
group.name,
arg
);
}

// Required groups should have at least one arg without default values
if group.required && !group.args.is_empty() {
assert!(
Expand All @@ -313,17 +324,6 @@ pub(crate) fn assert_app(cmd: &Command) {
group.name
)
}

for arg in &group.args {
// Args listed inside groups should exist
assert!(
cmd.get_arguments().any(|x| x.id == *arg),
"Command {}: Argument group '{}' contains non-existent argument '{:?}'",
cmd.get_name(),
group.name,
arg
);
}
}

// Conflicts between flags and subcommands
Expand Down

0 comments on commit 9713cd9

Please sign in to comment.