diff --git a/command.go b/command.go index 5b81f61d..7e55dcfd 100644 --- a/command.go +++ b/command.go @@ -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) {