Skip to content

Commit 24eff7e

Browse files
authored
Merge pull request #35 from go-tstr/cmd-args
Support passing args as option to cmd
2 parents 54acf7f + bcc79f2 commit 24eff7e

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)