MCPcopy
hub / github.com/spf13/cobra / Execute

Method Execute

command.go:1070–1073  ·  view source on GitHub ↗

Execute uses the args (os.Args[1:] by default) and run through the command tree finding appropriate matches for commands and then corresponding flags.

()

Source from the content-addressed store, hash-verified

1068// and run through the command tree finding appropriate matches
1069// for commands and then corresponding flags.
1070func (c *Command) Execute() error {
1071 _, err := c.ExecuteC()
1072 return err
1073}
1074
1075// ExecuteContextC is the same as ExecuteC(), but sets the ctx on the command.
1076// Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs

Callers 9

TestValidateFlagGroupsFunction · 0.95
TestDefaultCompletionCmdFunction · 0.95
testMethod · 0.95
TestSetContextFunction · 0.95
TestSetContextPreRunFunction · 0.95
ExecuteContextMethod · 0.95
tmplFunction · 0.80

Calls 1

ExecuteCMethod · 0.95

Tested by 7

TestValidateFlagGroupsFunction · 0.76
TestDefaultCompletionCmdFunction · 0.76
testMethod · 0.76
TestSetContextFunction · 0.76
TestSetContextPreRunFunction · 0.76