Documentation
¶
Overview ¶
Package exec runs external commands
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultDebugfFn is the default debug print function. DefaultDebugfFn = func(string, ...interface{}) {} // DefaultDebugPrefix is the default prefix that is prepended to messages passed to the debugf function. DefaultDebugPrefix = "exec: " )
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd represents a command that can be run.
func Command ¶
Command returns a new Cmd struct. If name contains no path separators, Command uses LookPath to resolve name to a complete path if possible. Otherwise it uses name directly as Path. By default a command is run in the current working directory.
func (*Cmd) DebugfFunc ¶
DebugfFunc sets the debug function for the command. It accepts a printf-style printf function and call it for every line that the command prints to STDOUT and STDERR when it's run.
func (*Cmd) DebugfPrefix ¶
DebugfPrefix sets a prefix that is prepended to the message that is passed to the Debugf function.
func (*Cmd) Env ¶
Env specifies the environment variables that the process uses. Each element is in the format KEY=VALUE.
func (*Cmd) ExpectSuccess ¶
ExpectSuccess if called, Run() will return an error if the command did not exit with code 0.
type ExitCodeError ¶
type ExitCodeError struct {
*Result
}
ExitCodeError is returned from Run() when a command exited with a code != 0.
func (ExitCodeError) Error ¶
func (e ExitCodeError) Error() string
Error returns the error description.
type Result ¶
Result describes the result of a run Cmd.
func (*Result) ExpectSuccess ¶
ExpectSuccess if the ExitCode in Result is not 0, the function returns an ExitCodeError for the execution.