MCPcopy Create free account
hub / github.com/dagger/dagger / loadCommand

Method loadCommand

cmd/dagger/functions.go:353–375  ·  view source on GitHub ↗

loadCommand finds the leaf command to run.

(c *cobra.Command, a []string)

Source from the content-addressed store, hash-verified

351
352// loadCommand finds the leaf command to run.
353func (fc *FuncCommand) loadCommand(c *cobra.Command, a []string) (rcmd *cobra.Command, rargs []string, rerr error) {
354 ctx := c.Context()
355
356 spanCtx, span := Tracer().Start(ctx, "parsing command line arguments", telemetry.Encapsulate())
357 defer telemetry.EndWithCause(span, &rerr)
358 fc.ctx = spanCtx
359
360 builder := fc.cobraBuilder(ctx, fc.mod.MainObject.AsObject.Constructor)
361
362 cmd, args, err := fc.traverse(c, a, builder)
363 if err != nil {
364 fc.logCommandParseSchemaSummary(ctx, "traverse_error", a, cmd, args, err)
365 return cmd, args, err
366 }
367
368 // There should be no args left, if there are it's an unknown command.
369 if err := cobra.NoArgs(cmd, args); err != nil {
370 fc.logCommandParseSchemaSummary(ctx, "remaining_args", a, cmd, args, err)
371 return cmd, args, err
372 }
373
374 return cmd, args, nil
375}
376
377func (fc *FuncCommand) logCommandParseSchemaSummary(ctx context.Context, reason string, requestedArgs []string, cmd *cobra.Command, remainingArgs []string, parseErr error) {
378 if fc == nil || fc.mod == nil {

Callers 1

executeMethod · 0.95

Calls 7

cobraBuilderMethod · 0.95
traverseMethod · 0.95
EncapsulateMethod · 0.80
TracerFunction · 0.70
ContextMethod · 0.65
StartMethod · 0.65

Tested by

no test coverage detected