(base *cobra.Command, plugins []Metadata, subCommand string)
| 375 | } |
| 376 | |
| 377 | func 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 | |
| 410 | func moveFile(sourcePath, destPath string) error { |
| 411 | inputFile, err := os.Open(sourcePath) |
no test coverage detected