Use VisibleFlags during doc generation

Hidden commands are excluded during doc generation but hidden flags are
not. Using VisibleFlags() instead of the Flags slice fixes that.

Signed-off-by: Link Dupont <link@sub-pop.net>
This commit is contained in:
Link Dupont 2019-12-18 14:46:13 -05:00
parent 460fa698ab
commit 777b332bb7
2 changed files with 6 additions and 2 deletions

View File

@ -48,8 +48,8 @@ func (a *App) writeDocTemplate(w io.Writer) error {
return t.ExecuteTemplate(w, name, &cliTemplate{
App: a,
Commands: prepareCommands(a.Commands, 0),
GlobalArgs: prepareArgsWithValues(a.Flags),
SynopsisArgs: prepareArgsSynopsis(a.Flags),
GlobalArgs: prepareArgsWithValues(a.VisibleFlags()),
SynopsisArgs: prepareArgsSynopsis(a.VisibleFlags()),
})
}

View File

@ -22,6 +22,10 @@ func testApp() *App {
Aliases: []string{"b"},
Usage: "another usage text",
},
&BoolFlag{
Name: "hidden-flag",
Hidden: true,
},
}
app.Commands = []*Command{{
Aliases: []string{"c"},