Skip to content

Commit

Permalink
fix(help): Hide subcommands in flattened usage
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 27, 2023
1 parent b656198 commit a9322ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 5 additions & 1 deletion clap_builder/src/output/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ impl<'cmd> Usage<'cmd> {
}
let mut cmd = self.cmd.clone();
cmd.build();
for (i, sub) in cmd.get_subcommands().enumerate() {
for (i, sub) in cmd
.get_subcommands()
.filter(|c| !c.is_hide_set())
.enumerate()
{
if i != 0 {
styled.trim_end();
let _ = write!(styled, "{}", USAGE_SEP);
Expand Down
3 changes: 0 additions & 3 deletions tests/builder/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,6 @@ fn flatten_single_hidden_command() {
parent command
Usage: parent [OPTIONS]
parent child1 [OPTIONS]
parent help [COMMAND]...
Options:
Expand Down Expand Up @@ -3346,7 +3345,6 @@ parent command
Usage: parent [OPTIONS]
parent child1 [OPTIONS]
parent child2 [OPTIONS]
parent child3 [OPTIONS]
parent help [COMMAND]...
Options:
Expand Down Expand Up @@ -3406,7 +3404,6 @@ Usage: parent [OPTIONS]
parent child1 grandchild3 [OPTIONS]
parent child1 help [COMMAND]
parent child2 [OPTIONS]
parent child3 [OPTIONS] [COMMAND]
parent help [COMMAND]...
Options:
Expand Down

0 comments on commit a9322ca

Please sign in to comment.