From bac5bde38c7725990645cf9b2bf2c824594f3963 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Wed, 11 Sep 2019 09:06:02 +0200 Subject: [PATCH] Don't generate fish completion for hidden commands Added the missing test case as well. Signed-off-by: Sascha Grunert --- docs_test.go | 3 +++ fish.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/docs_test.go b/docs_test.go index 6ffc995..f18d12d 100644 --- a/docs_test.go +++ b/docs_test.go @@ -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" diff --git a/fish.go b/fish.go index 1121a20..cf183af 100644 --- a/fish.go +++ b/fish.go @@ -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'",