diff --git a/cmd/hostctl/actions/completion.go b/cmd/hostctl/actions/completion.go index da7804c..9d6a6fe 100644 --- a/cmd/hostctl/actions/completion.go +++ b/cmd/hostctl/actions/completion.go @@ -8,14 +8,15 @@ import ( func newCompletionCmd(rootCmd *cobra.Command) *cobra.Command { completionCmd := &cobra.Command{ - Use: "completion ", - Short: "Generate bash or zsh completion script", + Use: "completion ", + Short: "Generate bash zsh or fish completion script", Hidden: true, } bashCompletionCmd := newBashCompletionCmd(rootCmd) zshCompletionCmd := newZshCompletionCmd(rootCmd) - completionCmd.AddCommand(bashCompletionCmd, zshCompletionCmd) + fishCompletionCmd := newFishCompletionCmd(rootCmd) + completionCmd.AddCommand(bashCompletionCmd, zshCompletionCmd, fishCompletionCmd) return completionCmd } @@ -39,3 +40,13 @@ func newZshCompletionCmd(rootCmd *cobra.Command) *cobra.Command { }, } } + +func newFishCompletionCmd(rootCmd *cobra.Command) *cobra.Command { + return &cobra.Command{ + Use: "fish", + Short: "Generate fish completion script", + RunE: func(cmd *cobra.Command, args []string) error { + return rootCmd.GenFishCompletion(os.Stdout, true) + }, + } +}