Skip to content

Commit

Permalink
add shell completions (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcalhoun committed Nov 16, 2022
1 parent 889e61c commit 9990f93
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/completion.go
@@ -0,0 +1,28 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
)

var CompletionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
Long: "To load completions",
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.ExactValidArgs(1),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
}
},
}

0 comments on commit 9990f93

Please sign in to comment.