Merge pull request #4867 from epage/panic

fix(builder): Assert earlier on bad requires/conflicts
This commit is contained in:
Ed Page 2023-04-27 18:57:19 -05:00 committed by GitHub
commit 9eaf8996a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View file

@ -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

View file

@ -439,7 +439,7 @@ impl<'cmd> Usage<'cmd> {
required_groups.insert(elem);
required_groups_members.extend(group_members);
} else {
debug_assert!(self.cmd.find(req).is_some());
debug_assert!(self.cmd.find(req).is_some(), "`{req}` must exist");
}
}