Skip to content

Commit

Permalink
Don't generate fish completion for hidden commands
Browse files Browse the repository at this point in the history
Added the missing test case as well.

Signed-off-by: Sascha Grunert <[email protected]>
  • Loading branch information
saschagrunert committed Sep 11, 2019
1 parent b207e20 commit bac5bde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func testApp() *App {
Usage: "retrieve generic information",
}, {
Name: "some-command",
}, {
Name: "hidden-command",
Hidden: true,
}}
app.UsageText = "app [first_arg] [second_arg]"
app.Usage = "Some app"
Expand Down
4 changes: 4 additions & 0 deletions fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (a *App) prepareFishCommands(commands []Command, allCommands *[]string, pre
for i := range commands {
command := &commands[i]

if command.Hidden {
continue
}

var completion strings.Builder
completion.WriteString(fmt.Sprintf(
"complete -r -c %s -n '%s' -a '%s'",
Expand Down

0 comments on commit bac5bde

Please sign in to comment.