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

Method Context

command.go:269–271  ·  view source on GitHub ↗

Context returns underlying command context. If command was executed with ExecuteContext or the context was set with SetContext, the previously set context will be returned. Otherwise, nil is returned. Notice that a call to Execute and ExecuteC will replace a nil context of a command with a context.

()

Source from the content-addressed store, hash-verified

267// a command with a context.Background, so a background context will be
268// returned by Context after one of these functions has been called.
269func (c *Command) Context() context.Context {
270 return c.ctx
271}
272
273// SetContext sets context for the command. This context will be overwritten by
274// Command.ExecuteContext or Command.ExecuteContextC.

Callers 9

TestExecuteContextFunction · 0.80
TestExecuteContextCFunction · 0.80
TestExecute_NoContextFunction · 0.80
TestSetContextFunction · 0.80
TestSetContextPreRunFunction · 0.80
TestHelpFuncExecutedFunction · 0.80

Calls

no outgoing calls

Tested by 9

TestExecuteContextFunction · 0.64
TestExecuteContextCFunction · 0.64
TestExecute_NoContextFunction · 0.64
TestSetContextFunction · 0.64
TestSetContextPreRunFunction · 0.64
TestHelpFuncExecutedFunction · 0.64