Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fish completion #151

Merged
merged 2 commits into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions cmd/completion.go
Expand Up @@ -13,7 +13,7 @@ func init() {

// completionCmd represents the completion command
var completionCmd = &cobra.Command{
Use: "completion <bash|zsh>",
Use: "completion <bash|zsh|fish>",
Short: "Generate bash/zsh completion scripts",
Long: `To load completion run

Expand All @@ -28,20 +28,23 @@ For bash:
source <(faas completion bash)

`,
ValidArgs: []string{"bash", "zsh"},
ValidArgs: []string{"bash", "zsh", "fish"},
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
if len(args) < 1 {
return errors.New("missing argument")
}
if args[0] == "bash" {
switch args[0] {
case "bash":
err = root.GenBashCompletion(os.Stdout)
return err
}
if args[0] == "zsh" {
case "zsh":
err = root.GenZshCompletion(os.Stdout)
return err
case "fish":
err = root.GenFishCompletion(os.Stdout, true)
default:
err = errors.New("unknown shell, only bash, zsh and fish are supported")
}
return errors.New("unknown shell, only bash and zsh are supported")

return err
},
}
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -7,7 +7,7 @@ require (
github.com/markbates/pkger v0.17.0
github.com/mitchellh/go-homedir v1.1.0
github.com/ory/viper v1.7.4
github.com/spf13/cobra v1.0.1-0.20200715031239-b95db644ed1c
github.com/spf13/cobra v1.0.1-0.20201006035406-b97b5ead31f7
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.8
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -1175,6 +1175,8 @@ github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHN
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.0.1-0.20200715031239-b95db644ed1c h1:nt+V0u9zwtHQLk4OrQxVDMwJ7ifwoUzqcrcxySbmxxY=
github.com/spf13/cobra v1.0.1-0.20200715031239-b95db644ed1c/go.mod h1:yk5b0mALVusDL5fMM6Rd1wgnoO5jUPhwsQ6LQAJTidQ=
github.com/spf13/cobra v1.0.1-0.20201006035406-b97b5ead31f7 h1:O63eWlXlvyw4YdsuatjRIU6emvJ2fqz+PTdMEoxIT2s=
github.com/spf13/cobra v1.0.1-0.20201006035406-b97b5ead31f7/go.mod h1:yk5b0mALVusDL5fMM6Rd1wgnoO5jUPhwsQ6LQAJTidQ=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down