Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(assert): Make sure group members exist before using them #3712

Merged
merged 1 commit into from May 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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