Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude hidden sub-command flags from docs #1346

Merged
merged 1 commit into from Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs.go
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
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
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