Add SetContext() function to cobra.Command

This commit is contained in:
Unknown 2020-05-19 17:07:08 -03:00
parent 94a87a7b83
commit d58c46a0d6

View file

@ -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) {