Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyUsed is an error that a Commander returns when an attempt // it made to reuse it. ErrAlreadyUsed = NewError("commander already used") // ErrNonZero is an error that a Commander returns when the command // finishes but the process return code is not 0. ErrNonZero = NewError("command exited with non-zero status") )
Functions ¶
Types ¶
type Commander ¶
type Commander interface { // Run executes the command with the same arguments as exec.Cmd. Run(command string, args ...string) error // Stdout returns standard output of the process as captured by the // underlying bytes.Buffer. Stdout() *bytes.Buffer // Stderr returns standard error of the process as captured by the // underlying bytes.Buffer. Stderr() *bytes.Buffer }
Commander is a testable interface built to capture the complexities of shelling out in Go.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a strongly typed error for the Commander module. Having these sort of errors can make our Bugsnag look more readable.
type MockCommander ¶
MockCommander is a mock implementation of lordcommander.Commander.
func (*MockCommander) Run ¶
func (mc *MockCommander) Run(command string, args ...string) error
Run is a mock implementation of Commander's Run method.
func (*MockCommander) Stderr ¶
func (mc *MockCommander) Stderr() *bytes.Buffer
Stderr is a mock implementation of Commander's Stderr method.
func (*MockCommander) Stdout ¶
func (mc *MockCommander) Stdout() *bytes.Buffer
Stdout is a mock implementation of Commander's Stdout method.
type Option ¶
type Option func(*commanderImpl)
Option is a function that can be passed to a Commander's constructor to change it's default behavior.
func DiscardStderr ¶
func DiscardStderr() Option
DiscardStderr tells the Commander not to capture standard error.
func DiscardStdout ¶
func DiscardStdout() Option
DiscardStdout tells the Commander not to capture standard output.
func WithContext ¶
WithContext allows changing Commander's default context.
func WithEnvironment ¶
WithEnvironment allows changing Commander's default environment.
func WithSignal ¶
WithSignal allows changing Commander's default termination signal.