Documentation
¶
Index ¶
- func Run(cmdStr string) (result string)
- type CommandBuilder
- func (cb *CommandBuilder) Add(cmds ...string) *CommandBuilder
- func (cb *CommandBuilder) ConcurRun() CommandProcs
- func (cb *CommandBuilder) Run() CommandProcs
- func (cb *CommandBuilder) Start() *CommandBuilder
- func (cb *CommandBuilder) Wait() CommandProcs
- func (cb *CommandBuilder) WithPolicy(policyMask CommandPolicy) *CommandBuilder
- type CommandPolicy
- type CommandProcs
- type Proc
- func (p *Proc) Command() *osexec.Cmd
- func (p *Proc) Err() error
- func (p *Proc) ExitCode() int
- func (p *Proc) Exited() bool
- func (p *Proc) ID() int
- func (p *Proc) IsSuccess() bool
- func (p *Proc) Kill() *Proc
- func (p *Proc) Out() io.Reader
- func (p *Proc) Peek() *Proc
- func (p *Proc) Result() string
- func (p *Proc) Start() *Proc
- func (p *Proc) StdErr() io.Reader
- func (p *Proc) StdOut() io.Reader
- func (p *Proc) SysTime() time.Duration
- func (p *Proc) UserTime() time.Duration
- func (p *Proc) Wait() *Proc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CommandBuilder ¶ added in v0.1.1
type CommandBuilder struct {
// contains filtered or unexported fields
}
func Commands ¶ added in v0.1.1
func Commands(cmds ...string) *CommandBuilder
Commands creates a *CommandBuilder used to collect command strings to be executed.
func (*CommandBuilder) Add ¶ added in v0.1.1
func (cb *CommandBuilder) Add(cmds ...string) *CommandBuilder
Add adds a new command string to the builder
func (*CommandBuilder) ConcurRun ¶ added in v0.1.1
func (cb *CommandBuilder) ConcurRun() CommandProcs
ConcurRun is a shortcut for executing procs concurrently:
cb.WithPolicy(CmdExecConcurrent).Start().Wait()
func (*CommandBuilder) Run ¶ added in v0.1.1
func (cb *CommandBuilder) Run() CommandProcs
Run is a shortcut for executing the procs serially:
cb.WithPolicy(CmdOnErrContinue).Start().Wait()
func (*CommandBuilder) Start ¶ added in v0.1.1
func (cb *CommandBuilder) Start() *CommandBuilder
Start starts running the registered procs serially and returns immediately. This should be followed by a call to Wait to retrieve results.
func (*CommandBuilder) Wait ¶ added in v0.1.1
func (cb *CommandBuilder) Wait() CommandProcs
func (*CommandBuilder) WithPolicy ¶ added in v0.1.1
func (cb *CommandBuilder) WithPolicy(policyMask CommandPolicy) *CommandBuilder
WithPolicy sets one or more command policy mask values, i.e. (CmdOnErrContinue | CmdExecConcurrent)
type CommandPolicy ¶ added in v0.1.1
type CommandPolicy byte
const ( CmdOnErrContinue CommandPolicy = 1 << iota CmdOnErrExit CmdExecSerial CmdExecConcurrent CmdExecPipe )
type CommandProcs ¶ added in v0.1.1
type CommandProcs struct {
// contains filtered or unexported fields
}
type Proc ¶
type Proc struct {
// contains filtered or unexported fields
}
Proc stores process info when running a process
func NewProc ¶ added in v0.1.1
NewProc sets up command string to be started as an OS process, however does not start the process.
func RunProc ¶
RunProc creates, runs, and waits for a process to complete and return *Proc with result info. This call must be followed by Proc.Result() to access command result as a string value. NOTE: using proc.Out(), after this call, will be empty.
func StartProc ¶
StartProc sets up and starts an OS process, but does not wait for it to complete (use proc.Wait for that)
func (*Proc) Out ¶
Out waits for cmd result and surfaces the result from both stdout and stderr in an io.Reader that can be streamed. NOTE: Must be called after Proc.StartProc
func (*Proc) Result ¶
Result waits and copies the result of the combined stdout and stderr and returns its result as a string. NOTE: Must be called after Proc.StartProc, Proc.RunProc() or Proc.Run().
func (*Proc) Start ¶ added in v0.1.1
Start starts the associated command as an OS process Errors can be accessed using p.Err()
func (*Proc) StdErr ¶
StdErr is an io.Reader pipe for standard error Must be streamed before Proc.Wait().