mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
fix(usage): Track all required
This commit is contained in:
parent
232c17ebc4
commit
05f8151d3d
2 changed files with 9 additions and 17 deletions
|
@ -824,8 +824,7 @@ impl<'help> App<'help> {
|
||||||
// before parsing incase we run into a subcommand
|
// before parsing incase we run into a subcommand
|
||||||
self._build();
|
self._build();
|
||||||
|
|
||||||
let mut parser = Parser::new(self);
|
let parser = Parser::new(self);
|
||||||
parser._build();
|
|
||||||
Usage::new(&parser.app, &parser.required).create_usage_with_title(&[])
|
Usage::new(&parser.app, &parser.required).create_usage_with_title(&[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,14 @@ impl<'help, 'app> Parser<'help, 'app> {
|
||||||
{
|
{
|
||||||
reqs.insert(a.id.clone());
|
reqs.insert(a.id.clone());
|
||||||
}
|
}
|
||||||
|
for group in &app.groups {
|
||||||
|
if group.required {
|
||||||
|
let idx = reqs.insert(group.id.clone());
|
||||||
|
for a in &group.requires {
|
||||||
|
reqs.insert_child(idx, a.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Parser {
|
Parser {
|
||||||
app,
|
app,
|
||||||
|
@ -60,20 +68,6 @@ impl<'help, 'app> Parser<'help, 'app> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does all the initializing and prepares the parser
|
|
||||||
pub(crate) fn _build(&mut self) {
|
|
||||||
debug!("Parser::_build");
|
|
||||||
|
|
||||||
for group in &self.app.groups {
|
|
||||||
if group.required {
|
|
||||||
let idx = self.required.insert(group.id.clone());
|
|
||||||
for a in &group.requires {
|
|
||||||
self.required.insert_child(idx, a.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should we color the help?
|
// Should we color the help?
|
||||||
pub(crate) fn color_help(&self) -> ColorChoice {
|
pub(crate) fn color_help(&self) -> ColorChoice {
|
||||||
#[cfg(feature = "color")]
|
#[cfg(feature = "color")]
|
||||||
|
@ -96,7 +90,6 @@ impl<'help, 'app> Parser<'help, 'app> {
|
||||||
) -> ClapResult<()> {
|
) -> ClapResult<()> {
|
||||||
debug!("Parser::get_matches_with");
|
debug!("Parser::get_matches_with");
|
||||||
// Verify all positional assertions pass
|
// Verify all positional assertions pass
|
||||||
self._build();
|
|
||||||
|
|
||||||
let mut subcmd_name: Option<String> = None;
|
let mut subcmd_name: Option<String> = None;
|
||||||
let mut keep_state = false;
|
let mut keep_state = false;
|
||||||
|
|
Loading…
Reference in a new issue