mirror of https://github.com/knative/func.git
feat: fish completion
This commit is contained in:
parent
bf9b048813
commit
d82230353d
|
@ -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
|
||||
|
||||
|
@ -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
go.mod
2
go.mod
|
@ -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
|
||||
|
|
2
go.sum
2
go.sum
|
@ -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=
|
||||
|
|
Loading…
Reference in New Issue