From 82a057811ebc9b8f42f16690684c8cf30fc9c495 Mon Sep 17 00:00:00 2001 From: crochee Date: Tue, 26 Oct 2021 13:59:32 +0800 Subject: [PATCH] add WithContext to set context --- command.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command.go b/command.go index 2cc18891..f04b3b65 100644 --- a/command.go +++ b/command.go @@ -230,6 +230,11 @@ func (c *Command) Context() context.Context { 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 // particularly useful when testing. func (c *Command) SetArgs(a []string) {