MCPcopy
hub / github.com/googleapis/mcp-toolbox / invokeCommand

Function invokeCommand

cmd/root_test.go:72–94  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

70}
71
72func invokeCommand(args []string) (*cobra.Command, *internal.ToolboxOptions, string, error) {
73 buf := new(bytes.Buffer)
74 opts := internal.NewToolboxOptions(internal.WithIOStreams(buf, buf))
75 c := NewCommand(opts)
76
77 // Keep the test output quiet
78 c.SilenceUsage = true
79 c.SilenceErrors = true
80
81 // Capture output
82 c.SetOut(buf)
83 c.SetErr(buf)
84 c.SetArgs(args)
85
86 // Disable execute behavior
87 c.RunE = func(*cobra.Command, []string) error {
88 return nil
89 }
90
91 err := c.Execute()
92
93 return c, opts, buf.String(), err
94}
95
96// invokeCommandWithContext executes the command with a context and returns the captured output.
97func invokeCommandWithContext(ctx context.Context, args []string) (*cobra.Command, *internal.ToolboxOptions, string, error) {

Callers 9

TestVersionFunction · 0.70
TestServerConfigFlagsFunction · 0.70
TestConfigFlagFunction · 0.70
TestConfigsFlagFunction · 0.70
TestConfigFolderFlagFunction · 0.70
TestPrebuiltFlagFunction · 0.70
TestDefaultLoggingFormatFunction · 0.70
TestDefaultLogLevelFunction · 0.70

Calls 4

NewToolboxOptionsFunction · 0.92
WithIOStreamsFunction · 0.92
NewCommandFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected