MCPcopy
hub / github.com/kubernetes/kubectl / NewCmdCompletion

Function NewCmdCompletion

pkg/cmd/completion/completion.go:125–144  ·  view source on GitHub ↗

NewCmdCompletion creates the `completion` command

(out io.Writer, boilerPlate string)

Source from the content-addressed store, hash-verified

123
124// NewCmdCompletion creates the `completion` command
125func 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
147func RunCompletion(out io.Writer, boilerPlate string, cmd *cobra.Command, args []string) error {

Callers 1

TestBashCompletionsFunction · 0.85

Calls 2

TFunction · 0.92
RunCompletionFunction · 0.85

Tested by 1

TestBashCompletionsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…