@@ -13,7 +13,7 @@ func init() {
13
13
14
14
// completionCmd represents the completion command
15
15
var completionCmd = & cobra.Command {
16
- Use : "completion <bash|zsh>" ,
16
+ Use : "completion <bash|zsh|fish >" ,
17
17
Short : "Generate bash/zsh completion scripts" ,
18
18
Long : `To load completion run
19
19
@@ -28,20 +28,23 @@ For bash:
28
28
source <(faas completion bash)
29
29
30
30
` ,
31
- ValidArgs : []string {"bash" , "zsh" },
31
+ ValidArgs : []string {"bash" , "zsh" , "fish" },
32
32
Args : cobra .ExactArgs (1 ),
33
33
RunE : func (cmd * cobra.Command , args []string ) (err error ) {
34
34
if len (args ) < 1 {
35
35
return errors .New ("missing argument" )
36
36
}
37
- if args [0 ] == "bash" {
37
+ switch args [0 ] {
38
+ case "bash" :
38
39
err = root .GenBashCompletion (os .Stdout )
39
- return err
40
- }
41
- if args [0 ] == "zsh" {
40
+ case "zsh" :
42
41
err = root .GenZshCompletion (os .Stdout )
43
- return err
42
+ case "fish" :
43
+ err = root .GenFishCompletion (os .Stdout , true )
44
+ default :
45
+ err = errors .New ("unknown shell, only bash, zsh and fish are supported" )
44
46
}
45
- return errors .New ("unknown shell, only bash and zsh are supported" )
47
+
48
+ return err
46
49
},
47
50
}
0 commit comments