Add Command.SetContext (#1551)
Increases flexibility in how Contexts can be used with Cobra.
This commit is contained in:
committed by
GitHub
parent
5d066b77b5
commit
f848943afd
@ -230,6 +230,12 @@ func (c *Command) Context() context.Context {
|
||||
return c.ctx
|
||||
}
|
||||
|
||||
// SetContext sets context for the command. It is set to context.Background by default and will be overwritten by
|
||||
// Command.ExecuteContext or Command.ExecuteContextC
|
||||
func (c *Command) SetContext(ctx context.Context) {
|
||||
c.ctx = ctx
|
||||
}
|
||||
|
||||
// SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden
|
||||
// particularly useful when testing.
|
||||
func (c *Command) SetArgs(a []string) {
|
||||
|
Reference in New Issue
Block a user