mirror of
https://github.com/spf13/cobra
synced 2025-05-07 13:57:21 +00:00
Add SetContext() function to cobra.Command
This commit is contained in:
parent
94a87a7b83
commit
d58c46a0d6
1 changed files with 6 additions and 0 deletions
|
@ -216,6 +216,12 @@ func (c *Command) Context() context.Context {
|
|||
return c.ctx
|
||||
}
|
||||
|
||||
// SetContext replaces the underlying command context so that parent
|
||||
// commands can pass down values to their subcommands.
|
||||
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue