MCPcopy
hub / github.com/helm/helm / loadCompletionForPlugin

Function loadCompletionForPlugin

pkg/cmd/load_plugins.go:221–237  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
221func 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

Callers 1

loadCLIPluginsFunction · 0.85

Calls 5

loadFileFunction · 0.85
addPluginCommandsFunction · 0.85
DirMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…