loadCompletionForPlugin will load and parse any completion.yaml provided by the plugin and add the dynamic completion hook to call the optional plugin.complete
(pluginCmd *cobra.Command, plug plugin.Plugin)
| 219 | // loadCompletionForPlugin will load and parse any completion.yaml provided by the plugin |
| 220 | // and add the dynamic completion hook to call the optional plugin.complete |
| 221 | func loadCompletionForPlugin(pluginCmd *cobra.Command, plug plugin.Plugin) { |
| 222 | // Parse the yaml file providing the plugin's sub-commands and flags |
| 223 | cmds, err := loadFile(strings.Join( |
| 224 | []string{plug.Dir(), pluginStaticCompletionFile}, string(filepath.Separator))) |
| 225 | |
| 226 | if err != nil { |
| 227 | // The file could be missing or invalid. No static completion for this plugin. |
| 228 | slog.Debug("plugin completion file loading", slog.String("error", err.Error())) |
| 229 | // Continue to setup dynamic completion. |
| 230 | cmds = &pluginCommand{} |
| 231 | } |
| 232 | |
| 233 | // Preserve the Usage string specified for the plugin |
| 234 | cmds.Name = pluginCmd.Use |
| 235 | |
| 236 | addPluginCommands(plug, pluginCmd, cmds) |
| 237 | } |
| 238 | |
| 239 | // addPluginCommands is a recursive method that adds each different level |
| 240 | // of sub-commands and flags for the plugins that have provided such information |
no test coverage detected
searching dependent graphs…