Documentation
¶
Index ¶
- Variables
- func GetCommandLine(command string, args ...string) string
- func Parse(commandLine string) (string, []string, errors.Error)
- func Quote(str string) string
- func Run(command string, args ...string) (string, int, errors.Error)
- func RunLine(commandLine string) (string, int, errors.Error)
- func ShouldRun(command string, args ...string) (string, errors.Error)
- func ShouldRunLine(commandLine string) (string, errors.Error)
- type Executor
- type LocalExecutor
- type MockExecutor
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRun occurs when a command could not be executed. ErrRun = errors.New("Could not execute command") // ErrReturnCode occurs when a command was executed but returned with a non-zero exit code. ErrReturnCode = errors.New("Process returned with code %d") // ErrParse occurs when a malformed command line was encountered. ErrParse = errors.New("Unable to parse command line") // DefaultExecutor denotes the Executor that is used by default for Run and RunLine commands. DefaultExecutor Executor )
Functions ¶
func GetCommandLine ¶
GetCommandLine is the inverse function of Parse. It assembles a single command line that is equivalent to the given command and arguments by escaping and quoting.
Types ¶
type Executor ¶
type Executor interface {
// RunLine executes an escaped single string command line.
RunLine(commandLine string) (string, int, errors.Error)
// Run executes a command line with separated arguments.
Run(command string, args ...string) (string, int, errors.Error)
}
Executor represents the interface for shell command execution.
type LocalExecutor ¶
type LocalExecutor struct {
}
LocalExecutor is used to execute commands on the local shell.
func NewLocalExecutor ¶
func NewLocalExecutor() *LocalExecutor
NewLocalExecutor returns an executor for the local shell.
type MockExecutor ¶
type MockExecutor struct {
RunCallback func(command string, args ...string) (string, int, errors.Error)
}
MockExecutor offers functionality to mock and debug executed commands.
func NewMockExecutor ¶
func NewMockExecutor(runCallback func(command string, args ...string) (string, int, errors.Error)) *MockExecutor
NewMockExecutor returns an executor for the local shell.
Click to show internal directories.
Click to hide internal directories.