Merge pull request #1346 from jolheiser/hidden-flag

Exclude hidden sub-command flags from docs
This commit is contained in:
Dan Buch 2022-04-25 23:05:43 -04:00 committed by GitHub
commit 924052a2f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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