Skip to content

Commit a9322ca

Browse files
committed
fix(help): Hide subcommands in flattened usage
1 parent b656198 commit a9322ca

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

clap_builder/src/output/usage.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ impl<'cmd> Usage<'cmd> {
113113
}
114114
let mut cmd = self.cmd.clone();
115115
cmd.build();
116-
for (i, sub) in cmd.get_subcommands().enumerate() {
116+
for (i, sub) in cmd
117+
.get_subcommands()
118+
.filter(|c| !c.is_hide_set())
119+
.enumerate()
120+
{
117121
if i != 0 {
118122
styled.trim_end();
119123
let _ = write!(styled, "{}", USAGE_SEP);

tests/builder/help.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,6 @@ fn flatten_single_hidden_command() {
33143314
parent command
33153315
33163316
Usage: parent [OPTIONS]
3317-
parent child1 [OPTIONS]
33183317
parent help [COMMAND]...
33193318
33203319
Options:
@@ -3346,7 +3345,6 @@ parent command
33463345
Usage: parent [OPTIONS]
33473346
parent child1 [OPTIONS]
33483347
parent child2 [OPTIONS]
3349-
parent child3 [OPTIONS]
33503348
parent help [COMMAND]...
33513349
33523350
Options:
@@ -3406,7 +3404,6 @@ Usage: parent [OPTIONS]
34063404
parent child1 grandchild3 [OPTIONS]
34073405
parent child1 help [COMMAND]
34083406
parent child2 [OPTIONS]
3409-
parent child3 [OPTIONS] [COMMAND]
34103407
parent help [COMMAND]...
34113408
34123409
Options:

0 commit comments

Comments
 (0)