|
|
|
@ -87,7 +87,7 @@ func (c *OSCommand) RunExecutable(cmd *exec.Cmd) error {
|
|
|
|
|
// ExecutableFromString takes a string like `docker ps -a` and returns an executable command for it
|
|
|
|
|
func (c *OSCommand) ExecutableFromString(commandStr string) *exec.Cmd {
|
|
|
|
|
splitCmd := str.ToArgv(commandStr)
|
|
|
|
|
return c.command(splitCmd[0], splitCmd[1:]...)
|
|
|
|
|
return c.NewCmd(splitCmd[0], splitCmd[1:]...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Same as ExecutableFromString but cancellable via a context
|
|
|
|
@ -96,6 +96,12 @@ func (c *OSCommand) ExecutableFromStringContext(ctx context.Context, commandStr
|
|
|
|
|
return exec.CommandContext(ctx, splitCmd[0], splitCmd[1:]...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *OSCommand) NewCmd(cmdName string, commandArgs ...string) *exec.Cmd {
|
|
|
|
|
cmd := c.command(cmdName, commandArgs...)
|
|
|
|
|
cmd.Env = os.Environ()
|
|
|
|
|
return cmd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *OSCommand) NewCommandStringWithShell(commandStr string) string {
|
|
|
|
|
var quotedCommand string
|
|
|
|
|
// Windows does not seem to like quotes around the command
|
|
|
|
@ -187,12 +193,7 @@ func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error) {
|
|
|
|
|
return nil, errors.New("No editor defined in $VISUAL or $EDITOR")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c.PrepareSubProcess(editor, filename), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it
|
|
|
|
|
func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) *exec.Cmd {
|
|
|
|
|
return c.command(cmdName, commandArgs...)
|
|
|
|
|
return c.NewCmd(editor, filename), nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Quote wraps a message in platform-specific quotation marks
|
|
|
|
@ -301,7 +302,7 @@ func (c *OSCommand) GetLazydockerPath() string {
|
|
|
|
|
|
|
|
|
|
// RunCustomCommand returns the pointer to a custom command
|
|
|
|
|
func (c *OSCommand) RunCustomCommand(command string) *exec.Cmd {
|
|
|
|
|
return c.PrepareSubProcess(c.Platform.shell, c.Platform.shellArg, command)
|
|
|
|
|
return c.NewCmd(c.Platform.shell, c.Platform.shellArg, command)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C
|
|
|
|
|