Documentation
¶
Overview ¶
Package cmdr Provide for quick build and run a cmd, batch run multi cmd tasks
Index ¶
- func FirstLine(output string) string
- func OutputLines(output string) []string
- type Cmd
- func (c *Cmd) AddArg(args ...string) *Cmd
- func (c *Cmd) AddArgf(format string, args ...interface{}) *Cmd
- func (c *Cmd) AddArgs(args []string) *Cmd
- func (c *Cmd) ArgIf(arg string, exprOk bool) *Cmd
- func (c *Cmd) Cmdline() string
- func (c *Cmd) CombinedOutput() (string, error)
- func (c *Cmd) FlushRun() error
- func (c *Cmd) GoCmd() *exec.Cmd
- func (c *Cmd) IDString() string
- func (c *Cmd) MustRun()
- func (c *Cmd) OnAfter(fn func(c *Cmd, err error)) *Cmd
- func (c *Cmd) OnBefore(fn func(c *Cmd)) *Cmd
- func (c *Cmd) Output() (string, error)
- func (c *Cmd) OutputLines() ([]string, error)
- func (c *Cmd) OutputToStd() *Cmd
- func (c *Cmd) ResetArgs()
- func (c *Cmd) Run() error
- func (c *Cmd) SafeLines() []string
- func (c *Cmd) SafeOutput() string
- func (c *Cmd) Success() bool
- func (c *Cmd) WithArg(args ...string) *Cmd
- func (c *Cmd) WithArgIf(arg string, exprOk bool) *Cmd
- func (c *Cmd) WithArgf(format string, args ...interface{}) *Cmd
- func (c *Cmd) WithArgs(args []string) *Cmd
- func (c *Cmd) WithArgsIf(args []string, exprOk bool) *Cmd
- func (c *Cmd) WithOutput(out, errOut io.Writer) *Cmd
- func (c *Cmd) WithStdin(in io.Reader) *Cmd
- func (c *Cmd) WithWorkDir(dir string) *Cmd
- type Errs
- type Runner
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cmd ¶
type Cmd struct {
*exec.Cmd
// Name of the command
Name string
// RunBefore hook
RunBefore func(c *Cmd)
// RunAfter hook
RunAfter func(c *Cmd, err error)
}
Cmd struct
func (*Cmd) CombinedOutput ¶
CombinedOutput run and return output, will combine stderr and stdout output
func (*Cmd) OutputLines ¶
OutputLines run and return output as lines
func (*Cmd) OutputToStd ¶
OutputToStd output to OS stdout and error
func (*Cmd) WithArgsIf ¶
WithArgsIf add arg and returns the current object
func (*Cmd) WithOutput ¶
WithOutput returns the current argument
func (*Cmd) WithWorkDir ¶
WithWorkDir returns the current object
type Runner ¶
type Runner struct {
// Errs on run tasks
Errs Errs
// IgnoreErr continue on error
IgnoreErr bool
RunBefore func(r *Runner) bool
RunAfter func(r *Runner)
ListenPrev func(t *Task) bool
EachBefore func(c *Cmd) bool
// contains filtered or unexported fields
}
Runner use for batch run multi task commands
Click to show internal directories.
Click to hide internal directories.