MCPcopy
hub / github.com/dagger/dagger / Execute

Method Execute

cmd/dagger/shell_commands.go:133–162  ·  view source on GitHub ↗

Execute is the main dispatcher function for shell builtin commands

(ctx context.Context, h *shellCallHandler, args []string, st *ShellState)

Source from the content-addressed store, hash-verified

131
132// Execute is the main dispatcher function for shell builtin commands
133func (c *ShellCommand) Execute(ctx context.Context, h *shellCallHandler, args []string, st *ShellState) error {
134 switch c.State {
135 case AnyState:
136 case RequiredState:
137 if st == nil {
138 return fmt.Errorf("command %q must be piped\n\nUsage: %s", c.Name(), c.Use)
139 }
140 case NoState:
141 if st != nil {
142 return fmt.Errorf("command %q cannot be piped\n\nUsage: %s", c.Name(), c.Use)
143 }
144 }
145 if c.Args != nil {
146 if err := c.Args(args); err != nil {
147 return fmt.Errorf("command %q %w\n\nUsage: %s", c.Name(), err, c.Use)
148 }
149 }
150 if !c.NoResolveStateArgs {
151 // resolve state values in arguments
152 a, err := h.resolveResults(ctx, args)
153 if err != nil {
154 return err
155 }
156 args = a
157 }
158 if h.Debug() {
159 shellDebug(ctx, "Command: "+c.Name(), args, st)
160 }
161 return c.Run(ctx, c, args, st)
162}
163
164func (h *shellCallHandler) BuiltinCommand(name string) (*ShellCommand, error) {
165 if name == "." || !strings.HasPrefix(name, ".") || strings.Contains(name, "/") {

Callers 15

IDMethod · 0.45
ValueMethod · 0.45
AsStringMethod · 0.45
DigestMethod · 0.45
IDMethod · 0.45
IsNullMethod · 0.45
NameMethod · 0.45
TypeNameMethod · 0.45
IDMethod · 0.45
AddedPathsMethod · 0.45
DiffStatsMethod · 0.45
ExportMethod · 0.45

Calls 6

NameMethod · 0.95
shellDebugFunction · 0.85
resolveResultsMethod · 0.80
RunMethod · 0.65
ArgsMethod · 0.45
DebugMethod · 0.45