mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Merge pull request #4867 from epage/panic
fix(builder): Assert earlier on bad requires/conflicts
This commit is contained in:
commit
9eaf8996a4
2 changed files with 23 additions and 1 deletions
|
@ -300,6 +300,28 @@ pub(crate) fn assert_app(cmd: &Command) {
|
||||||
arg
|
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
|
// Conflicts between flags and subcommands
|
||||||
|
|
|
@ -439,7 +439,7 @@ impl<'cmd> Usage<'cmd> {
|
||||||
required_groups.insert(elem);
|
required_groups.insert(elem);
|
||||||
required_groups_members.extend(group_members);
|
required_groups_members.extend(group_members);
|
||||||
} else {
|
} else {
|
||||||
debug_assert!(self.cmd.find(req).is_some());
|
debug_assert!(self.cmd.find(req).is_some(), "`{req}` must exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue