Documentation
¶
Overview ¶
Package run provides strategies for running command with a uniform interface. This packages requires github.com/go-cmd/cmd.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRunning is returned by a Runner if its Run method is called while still running. ErrRunning = errors.New("already running") // ErrStopped is returned by a Runner if its Stop method is called before Run finishes. ErrStopped = errors.New("Stop called") // ErrNonzeroExit is returned by a Runner if a Cmd returns a non-zero exit code. ErrNonzeroExit = errors.New("non-zero exit") )
Functions ¶
This section is empty.
Types ¶
type Factory ¶
A Factory makes a Runner for the given strategy. This is useful for testing: mock runners can be returned instead of real runners when testing to avoid running real commands.
type RunSync ¶
RunSync is a Runner that runs commands synchronously in the order given. No timeouts or retries are used. It's the simplest possible Runner which expects all commands to be quick and reliable.
func NewRunSync ¶
NewRunSync creates a new RunSync. If stopOnError is true, Run stops immediately and returns ErrNonzeroExit when a command exits non-zero.
type Runner ¶
A Runner runs a list of commands. The interface is intentionally trivial because the real benefit lies in its implementation. For example, RunSync runs commands synchronously in the order given without retries or timeouts. Another implementation could implement a more complex strategy, for example, running commands in parallel. The implementation details are hidden from and irrelevant to the caller, which allows the caller to focus on running commands, not how they are ran.