mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
Merge pull request #3712 from epage/assert
fix(assert): Make sure group members exist before using them
This commit is contained in:
commit
9713cd9ae4
1 changed files with 11 additions and 11 deletions
|
@ -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!(
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue