package icmd

// CmdOp is an operation which modified a Cmd structure used to execute commands
type CmdOp func(*Cmd)

package icmd

import (
	"io"
	"time"
)

// CmdOp is an operation which modified a Cmd structure used to execute commands
type CmdOp func(*Cmd)

// WithTimeout sets the timeout duration of the command
func WithTimeout(timeout time.Duration) CmdOp {
	return func(c *Cmd) {
		c.Timeout = timeout
	}
}

// WithEnv sets the environment variable of the command.
// Each arguments are in the form of KEY=VALUE
func WithEnv(env ...string) CmdOp {
	return func(c *Cmd) {
		c.Env = env
	}
}

// Dir sets the working directory of the command
func Dir(path string) CmdOp {
	return func(c *Cmd) {
		c.Dir = path
	}
}

// WithStdin sets the standard input of the command to the specified reader
func WithStdin(r io.Reader) CmdOp {
	return func(c *Cmd) {
		c.Stdin = r
	}
}

Add some CmdOps to make `RunCmd` more useful
Add some CmdOps to make `RunCmd` more useful

adding WithTimeout, WithEnv, Dir and WithStdin as I think those are
the most used/required.

Signed-off-by: Vincent Demeester <87e1f221a672a14a323e57bb65eaea19d3ed3804@sbr.pm>
