isCompletionCommand returns true if args indicate a shell completion request. Update notifications and Shutdown lifecycle emits must be suppressed for these to avoid corrupting machine-parseable completion output and to avoid firing plugin Shutdown handlers on every Tab keystroke. Cobra dispatches
(args []string)
| 213 | // ShellCompNoDescRequestCmd). Check both, otherwise bash/zsh completion |
| 214 | // (which often uses NoDesc) silently bypasses the gate. |
| 215 | func isCompletionCommand(args []string) bool { |
| 216 | for _, arg := range args { |
| 217 | if arg == "completion" || arg == "__complete" || arg == "__completeNoDesc" { |
| 218 | return true |
| 219 | } |
| 220 | } |
| 221 | return false |
| 222 | } |
| 223 | |
| 224 | // configureFlagCompletions enables cmdutil.RegisterFlagCompletion only when |
| 225 | // the invocation will actually serve a __complete request. |
no outgoing calls