Merge pull request #1346 from jolheiser/hidden-flag

Exclude hidden sub-command flags from docs
This commit is contained in:
2022-04-25 23:05:43 -04:00
committed by GitHub
3 changed files with 8 additions and 3 deletions

View File

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

View File

@@ -103,6 +103,11 @@ Should be a part of the same code block
Aliases: []string{"s"},
Usage: "some usage text",
},
&StringFlag{
Name: "sub-command-hidden-flag",
Usage: "some hidden usage text",
Hidden: true,
},
},
Name: "sub-usage",
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,
a.prepareFishFlags(command.Flags, command.Names())...,
a.prepareFishFlags(command.VisibleFlags(), command.Names())...,
)
// recursevly iterate subcommands