Skip to content

Commit

Permalink
fix(builder): Assert earlier on bad requires/conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 27, 2023
1 parent e02644b commit 185729a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions clap_builder/src/builder/debug_asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,28 @@ pub(crate) fn assert_app(cmd: &Command) {
arg
);
}

for arg in &group.requires {
// Args listed inside groups should exist
assert!(
cmd.id_exists(arg),
"Command {}: Argument group '{}' requires non-existent '{}' id",
cmd.get_name(),
group.get_id(),
arg
);
}

for arg in &group.conflicts {
// Args listed inside groups should exist
assert!(
cmd.id_exists(arg),
"Command {}: Argument group '{}' conflicts with non-existent '{}' id",
cmd.get_name(),
group.get_id(),
arg
);
}
}

// Conflicts between flags and subcommands
Expand Down

0 comments on commit 185729a

Please sign in to comment.