[common] add NewTokenizedShellCmd to ShellCmd

This commit is contained in:
Alex Quick committed 2017-09-27 23:56:39 -04:00
1 parent ef95d2bcd4
commit e57e1408b2
1 file changed
+8 -3
+8 -3
View File
@@ -22,11 +22,16 @@ type ShellCmd struct {
// NewShellCmd returns a new ShellCmd struct // NewShellCmd returns a new ShellCmd struct
func NewShellCmd(command string) *ShellCmd { func NewShellCmd(command string) *ShellCmd {
items := strings.Split(command, " ") items := strings.Split(command, " ")
cmd := items[0] return NewTokenizedShellCmd(items...)
args := items[1:] }
// NewTokenizedShellCmd creates a new ShellCmd
func NewTokenizedShellCmd(command ...string) *ShellCmd {
cmd := command[0]
args := command[1:]
return &ShellCmd{ return &ShellCmd{
Command: exec.Command(cmd, args...), Command: exec.Command(cmd, args...),
CommandString: command, CommandString: strings.Join(command, " "),
Args: args, Args: args,
ShowOutput: true, ShowOutput: true,
} }