Exclude hidden sub-command flags from docs

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
jolheiser 2022-04-18 20:58:38 -05:00
parent 7b2e60968b
commit e7157a87d9
No known key found for this signature in database
GPG Key ID: B853ADA5DA7BBF7A
3 changed files with 8 additions and 3 deletions

View File

@ -80,14 +80,14 @@ func prepareCommands(commands []*Command, level int) []string {
usageText, usageText,
) )
flags := prepareArgsWithValues(command.Flags) flags := prepareArgsWithValues(command.VisibleFlags())
if len(flags) > 0 { if len(flags) > 0 {
prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n")) prepared += fmt.Sprintf("\n%s", strings.Join(flags, "\n"))
} }
coms = append(coms, prepared) coms = append(coms, prepared)
// recursevly iterate subcommands // recursively iterate subcommands
if len(command.Subcommands) > 0 { if len(command.Subcommands) > 0 {
coms = append( coms = append(
coms, coms,

View File

@ -103,6 +103,11 @@ Should be a part of the same code block
Aliases: []string{"s"}, Aliases: []string{"s"},
Usage: "some usage text", Usage: "some usage text",
}, },
&StringFlag{
Name: "sub-command-hidden-flag",
Usage: "some hidden usage text",
Hidden: true,
},
}, },
Name: "sub-usage", Name: "sub-usage",
Usage: "standard usage text", Usage: "standard usage text",

View File

@ -95,7 +95,7 @@ func (a *App) prepareFishCommands(commands []*Command, allCommands *[]string, pr
completions = append(completions, completion.String()) completions = append(completions, completion.String())
completions = append( completions = append(
completions, completions,
a.prepareFishFlags(command.Flags, command.Names())..., a.prepareFishFlags(command.VisibleFlags(), command.Names())...,
) )
// recursevly iterate subcommands // recursevly iterate subcommands