NewCmdCompletion creates the `completion` command
(out io.Writer, boilerPlate string)
| 123 | |
| 124 | // NewCmdCompletion creates the `completion` command |
| 125 | func NewCmdCompletion(out io.Writer, boilerPlate string) *cobra.Command { |
| 126 | shells := []string{} |
| 127 | for s := range completionShells { |
| 128 | shells = append(shells, s) |
| 129 | } |
| 130 | |
| 131 | cmd := &cobra.Command{ |
| 132 | Use: "completion SHELL", |
| 133 | DisableFlagsInUseLine: true, |
| 134 | Short: i18n.T("Output shell completion code for the specified shell (bash, zsh, fish, or powershell)"), |
| 135 | Long: completionLong, |
| 136 | Example: completionExample, |
| 137 | Run: func(cmd *cobra.Command, args []string) { |
| 138 | cmdutil.CheckErr(RunCompletion(out, boilerPlate, cmd, args)) |
| 139 | }, |
| 140 | ValidArgs: shells, |
| 141 | } |
| 142 | |
| 143 | return cmd |
| 144 | } |
| 145 | |
| 146 | // RunCompletion checks given arguments and executes command |
| 147 | func RunCompletion(out io.Writer, boilerPlate string, cmd *cobra.Command, args []string) error { |
searching dependent graphs…