Documentation ¶
Index ¶
- Variables
- type Commander
- type CommanderOption
- func Apply(ops ...CommanderOption) CommanderOption
- func Async() CommanderOption
- func Binary(bin string, flag string) CommanderOption
- func Command(c string, m ...interface{}) CommanderOption
- func Commands(p ...string) CommanderOption
- func Dir(p string) CommanderOption
- func Envs(envs map[string]string) CommanderOption
- func Err(err io.Writer) CommanderOption
- func Input(in io.Reader) CommanderOption
- func Output(out io.Writer) CommanderOption
- func SetAsync(b bool) CommanderOption
- func Sync() CommanderOption
- func Timeout(d time.Duration) CommanderOption
Constants ¶
This section is empty.
Variables ¶
var (
ErrCommandFailed = errors.New("Command failed to execute succcesfully")
)
errors ...
Functions ¶
This section is empty.
Types ¶
type Commander ¶
type Commander struct { Async bool Command string SubCommands []string Timeout time.Duration Dir string Binary string Flag string Envs map[string]string In io.Reader Out io.Writer Err io.Writer }
Commander runs provided command within a /bin/sh -c "{COMMAND}", returning response associatedly. It also attaches if provided stdin, stdout and stderr readers/writers. Commander allows you to set the binary to use and flag, where each defaults to /bin/sh for binary and -c for flag respectively.
func ApplyImmediate ¶
func ApplyImmediate(cm *Commander, ops ...CommanderOption) *Commander
ApplyImmediate applies the options immediately to the Commander.
type CommanderOption ¶
type CommanderOption func(*Commander)
CommanderOption defines a function type that aguments a commander's field.
func Apply ¶
func Apply(ops ...CommanderOption) CommanderOption
Apply takes the giving series of CommandOption returning a function that always applies them to passed in commanders.
func Binary ¶
func Binary(bin string, flag string) CommanderOption
Binary sets the binary command for the Commander.
func Command ¶
func Command(c string, m ...interface{}) CommanderOption
Command sets the command for the Commander.
func Commands ¶
func Commands(p ...string) CommanderOption
Commands sets the subcommands for the Commander exec call. If subcommands are set then the Binary, Flag and Command are ignored and the values of the subcommand is used.
func Envs ¶
func Envs(envs map[string]string) CommanderOption
Envs sets the map of environment for the Commander.
func Input ¶
func Input(in io.Reader) CommanderOption
Input sets the input reader for the Commander.
func Output ¶
func Output(out io.Writer) CommanderOption
Output sets the output writer for the Commander.
func Timeout ¶
func Timeout(d time.Duration) CommanderOption
Timeout sets the commander to run in synchronouse mode.