[common] add NewTokenizedShellCmd to ShellCmd

This commit is contained in:
Alex Quick
2017-01-16 23:07:20 -05:00
parent ef95d2bcd4
commit e57e1408b2

View File

@@ -22,11 +22,16 @@ type ShellCmd struct {
// NewShellCmd returns a new ShellCmd struct
func NewShellCmd(command string) *ShellCmd {
items := strings.Split(command, " ")
cmd := items[0]
args := items[1:]
return NewTokenizedShellCmd(items...)
}
// NewTokenizedShellCmd creates a new ShellCmd
func NewTokenizedShellCmd(command ...string) *ShellCmd {
cmd := command[0]
args := command[1:]
return &ShellCmd{
Command: exec.Command(cmd, args...),
CommandString: command,
CommandString: strings.Join(command, " "),
Args: args,
ShowOutput: true,
}