Skip to content

Commit

Permalink
imp: if all subcommands are hidden, the subcommands section of the he…
Browse files Browse the repository at this point in the history
…lp message is no longer displayed

Closes #1046
  • Loading branch information
kbknapp committed Sep 14, 2017
1 parent e1319fa commit 4ae7b04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl<'a> Help<'a> {
.filter(|arg| !arg.is_set(ArgSettings::Hidden))
.count() > 0;
let opts = parser.has_opts();
let subcmds = parser.has_subcommands();
let subcmds = parser.has_visible_subcommands();

let unified_help = parser.is_set(AppSettings::UnifiedHelpMessage);

Expand Down
5 changes: 1 addition & 4 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,7 @@ impl<'a, 'b> Parser<'a, 'b>

#[inline]
pub fn has_visible_subcommands(&self) -> bool {
if self.subcommands.is_empty() {
return false;
}
self.subcommands.iter().any(|s| !s.p.is_set(AS::Hidden))
self.has_subcommands() && self.subcommands.iter().filter(|sc| sc.p.meta.name != "help").any(|sc| !sc.p.is_set(AS::Hidden))
}

#[inline]
Expand Down

0 comments on commit 4ae7b04

Please sign in to comment.