From ea4db7eef470a6c198c2fca623d1047c1de65ad8 Mon Sep 17 00:00:00 2001 From: joshcarp Date: Mon, 6 Dec 2021 21:23:45 +1100 Subject: [PATCH] Add Command.SetContext --- command.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/command.go b/command.go index 2cc18891..c973d322 100644 --- a/command.go +++ b/command.go @@ -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) {