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

Function NewRunCmd

cmd/run.go:48–90  ·  view source on GitHub ↗

NewRunCmd creates a new run command

(f factory.Factory, globalFlags *flags.GlobalFlags, rawConfig *RawConfig)

Source from the content-addressed store, hash-verified

46
47// NewRunCmd creates a new run command
48func NewRunCmd(f factory.Factory, globalFlags *flags.GlobalFlags, rawConfig *RawConfig) *cobra.Command {
49 cmd := &RunCmd{
50 GlobalFlags: globalFlags,
51 Stdout: os.Stdout,
52 Stderr: os.Stderr,
53 }
54
55 runCmd := &cobra.Command{
56 Use: "run",
57 DisableFlagParsing: true,
58 Short: "Executes a predefined command",
59 Long: `
60#######################################################
61##################### devspace run ####################
62#######################################################
63Executes a predefined command from the devspace.yaml
64
65Examples:
66devspace run mycommand --myarg 123
67devspace run mycommand2 1 2 3
68devspace --dependency my-dependency run any-command --any-command-flag
69#######################################################
70 `,
71 Args: cobra.MinimumNArgs(1),
72 }
73 runCmd.RunE = func(cobraCmd *cobra.Command, _ []string) error {
74 args, err := ParseArgs(runCmd, cmd.GlobalFlags, f.GetLog())
75 if err != nil {
76 return err
77 }
78
79 plugin.SetPluginCommand(cobraCmd, args)
80 return cmd.RunRun(f, args)
81 }
82
83 if rawConfig != nil && rawConfig.Config != nil {
84 for _, cmd := range rawConfig.Config.Commands {
85 runCmd.AddCommand(NewSpecificRunCommand(cmd))
86 }
87 }
88 runCmd.Flags().StringVar(&cmd.Dependency, "dependency", "", "Run a command from a specific dependency")
89 return runCmd
90}
91
92// RunRun executes the functionality "devspace run"
93func (cmd *RunCmd) RunRun(f factory.Factory, args []string) error {

Callers 1

BuildRootFunction · 0.70

Calls 5

RunRunMethod · 0.95
SetPluginCommandFunction · 0.92
ParseArgsFunction · 0.85
NewSpecificRunCommandFunction · 0.85
GetLogMethod · 0.65

Tested by

no test coverage detected