Skip to content

Commit bcc79f2

Browse files
committed
Support passing args as option to cmd
1 parent 54acf7f commit bcc79f2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

dep/cmd/cmd.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,22 @@ func WithEnvAppend(env ...string) Opt {
152152
}
153153
}
154154

155+
// WithArgsSet sets arguments for the command.
156+
func WithArgsSet(args ...string) Opt {
157+
return func(c *Cmd) error {
158+
c.cmd.Args = args
159+
return nil
160+
}
161+
}
162+
163+
// WithArgsAppend adds arguments to commands current argument list.
164+
func WithArgsAppend(args ...string) Opt {
165+
return func(c *Cmd) error {
166+
c.cmd.Args = append(c.cmd.Args, args...)
167+
return nil
168+
}
169+
}
170+
155171
// WithDir sets the working directory for the command.
156172
func WithDir(dir string) Opt {
157173
return func(c *Cmd) error {

0 commit comments

Comments
 (0)