mirror of
https://github.com/spf13/cobra
synced 2025-05-05 12:57:22 +00:00
add WithContext to set context
This commit is contained in:
parent
c1973d31bf
commit
82a057811e
1 changed files with 5 additions and 0 deletions
|
@ -230,6 +230,11 @@ func (c *Command) Context() context.Context {
|
||||||
return c.ctx
|
return c.ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithContext its context changed to ctx. The provided ctx must be non-nil.
|
||||||
|
func (c *Command) WithContext(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
|
// SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden
|
||||||
// particularly useful when testing.
|
// particularly useful when testing.
|
||||||
func (c *Command) SetArgs(a []string) {
|
func (c *Command) SetArgs(a []string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue