-
Notifications
You must be signed in to change notification settings - Fork 71
/
completions.go
51 lines (44 loc) · 1.07 KB
/
completions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{Use: "completion"}
func completionBashCmd() *cobra.Command {
var completionCmd = &cobra.Command{
Use: "bash",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return rootCmd.GenBashCompletion(os.Stdout)
},
}
return completionCmd
}
func completionZshCmd() *cobra.Command {
var completionCmd = &cobra.Command{
Use: "zsh",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return rootCmd.GenZshCompletion(os.Stdout)
},
}
return completionCmd
}
func completionFishCmd() *cobra.Command {
var completionCmd = &cobra.Command{
Use: "fish",
Hidden: true,
RunE: func(cmd *cobra.Command, args []string) error {
return rootCmd.GenFishCompletion(os.Stdout, true)
},
}
return completionCmd
}
func init() {
completionCmd.AddCommand(completionBashCmd())
completionCmd.AddCommand(completionZshCmd())
completionCmd.AddCommand(completionFishCmd())
CliCommands = append(CliCommands, cliCommand{
Cmd: completionCmd,
})
}