Skip to content

Commit 924052a

Browse files
authored
Merge pull request #1346 from jolheiser/hidden-flag
Exclude hidden sub-command flags from docs
2 parents e275e95 + e7157a8 commit 924052a

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ func prepareCommands(commands []*Command, level int) []string {
8080
usageText,
8181
)
8282

83-
flags := prepareArgsWithValues(command.Flags)
83+
flags := prepareArgsWithValues(command.VisibleFlags())
8484
if len(flags) > 0 {
8585
prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n"))
8686
}
8787

8888
coms = append(coms, prepared)
8989

90-
// recursevly iterate subcommands
90+
// recursively iterate subcommands
9191
if len(command.Subcommands) > 0 {
9292
coms = append(
9393
coms,

docs_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ Should be a part of the same code block
103103
Aliases: []string{"s"},
104104
Usage: "some usage text",
105105
},
106+
&StringFlag{
107+
Name: "sub-command-hidden-flag",
108+
Usage: "some hidden usage text",
109+
Hidden: true,
110+
},
106111
},
107112
Name: "sub-usage",
108113
Usage: "standard usage text",

fish.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr
9595
completions = append(completions, completion.String())
9696
completions = append(
9797
completions,
98-
a.prepareFishFlags(command.Flags, command.Names())...,
98+
a.prepareFishFlags(command.VisibleFlags(), command.Names())...,
9999
)
100100

101101
// recursevly iterate subcommands

0 commit comments

Comments
 (0)