MCPcopy Index your code
hub / github.com/devspace-sh/devspace / AddPluginCommands

Function AddPluginCommands

pkg/devspace/plugin/plugin.go:377–408  ·  view source on GitHub ↗
(base *cobra.Command, plugins []Metadata, subCommand string)

Source from the content-addressed store, hash-verified

375}
376
377func AddPluginCommands(base *cobra.Command, plugins []Metadata, subCommand string) {
378 for _, plugin := range plugins {
379 pluginFolder := plugin.PluginFolder
380 for _, pluginCommand := range plugin.Commands {
381 if pluginCommand.SubCommand == subCommand {
382 md := pluginCommand
383 if md.Usage == "" {
384 md.Usage = fmt.Sprintf("the %q plugin", plugin.Name)
385 }
386
387 c := &cobra.Command{
388 Use: md.Name,
389 Short: md.Usage,
390 Long: md.Description,
391 RunE: func(cmd *cobra.Command, args []string) error {
392 newArgs := []string{}
393 newArgs = append(newArgs, md.BaseArgs...)
394 newArgs = append(newArgs, args...)
395 return CallPluginExecutable(filepath.Join(pluginFolder, PluginBinary), newArgs, devspaceVars, os.Stdout)
396 },
397 // This passes all the flags to the subcommand.
398 DisableFlagParsing: true,
399 Annotations: map[string]string{
400 PluginCommandAnnotation: "true",
401 },
402 }
403
404 base.AddCommand(c)
405 }
406 }
407 }
408}
409
410func moveFile(sourcePath, destPath string) error {
411 inputFile, err := os.Open(sourcePath)

Callers 9

BuildRootFunction · 0.92
NewResetCmdFunction · 0.92
NewUseCmdFunction · 0.92
NewUpdateCmdFunction · 0.92
NewRemoveCmdFunction · 0.92
NewListCmdFunction · 0.92
NewSetCmdFunction · 0.92
NewAddCmdFunction · 0.92
NewCleanupCmdFunction · 0.92

Calls 1

CallPluginExecutableFunction · 0.85

Tested by

no test coverage detected