Skip to content

Commit

Permalink
Use VisibleFlags during doc generation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
subpop committed Dec 19, 2019
1 parent 460fa69 commit 777b332
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
})
}

Expand Down
4 changes: 4 additions & 0 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 777b332

Please sign in to comment.