Skip to content

Commit

Permalink
Merge pull request #1346 from jolheiser/hidden-flag
Browse files Browse the repository at this point in the history
Exclude hidden sub-command flags from docs
  • Loading branch information
meatballhat authored Apr 26, 2022
2 parents e275e95 + e7157a8 commit 924052a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 924052a

Please sign in to comment.