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 ¶ added in v0.15.0
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 ShellCommand ¶ added in v0.15.0
ShellCommand executes a command in sh shell.
func (*Cmd) DebugfFunc ¶ added in v0.15.0
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 ¶ added in v0.15.0
DebugfPrefix sets a prefix that is prepended to the message that is passed to the Debugf function.
func (*Cmd) Directory ¶ added in v0.15.0
Directory changes the directory in which the command is executed.
func (*Cmd) ExpectSuccess ¶ added in v0.15.0
ExpectSuccess if called, Run() will return an error if the command did not exit with code 0.
type ExitCodeError ¶ added in v0.15.0
type ExitCodeError struct {
*Result
}
ExitCodeError is returned from Run() when a command exited with a code != 0.
func (ExitCodeError) Error ¶ added in v0.15.0
func (e ExitCodeError) Error() string
Error returns the error description.
type Result ¶ added in v0.15.0
Result describes the result of a run Cmd.
func (*Result) ExpectSuccess ¶ added in v0.15.0
ExpectSuccess if the ExitCode in Result is not 0, the function returns an ExitCodeError for the execution.