Documentation ¶
Index ¶
- func BytesToLines(data []byte) []string
- func IterateLines(data []byte, f func(string) error) error
- func Run(cmd ...*exec.Cmd) error
- type Cmd
- func (t *Cmd) Add(cmd *exec.Cmd) *Cmd
- func (t *Cmd) CombineOutput() *Cmd
- func (t *Cmd) Dir(dir string) *Cmd
- func (t *Cmd) ErrorTo(w io.Writer) *Cmd
- func (t *Cmd) InputBytes(bytes []byte) *Cmd
- func (t *Cmd) InputFile(file string) *Cmd
- func (t *Cmd) InputString(text string) *Cmd
- func (t *Cmd) PipeTo(name string, arg ...string) *Cmd
- func (t *Cmd) Run()
- func (t *Cmd) ToBytes() []byte
- func (t *Cmd) ToFile(file string)
- func (t *Cmd) ToLines() []string
- func (t *Cmd) ToNull()
- func (t *Cmd) ToString() string
- func (t *Cmd) ToWriter(out io.Writer)
- type ErrorHandler
- type Errors
- type Script
- func (t *Script) AddError(err error)
- func (t *Script) Cmd(name string, args ...string) *Cmd
- func (t *Script) Error() error
- func (t *Script) HasError() bool
- func (t *Script) LogWriter() io.Writer
- func (t *Script) Pipeline() *Cmd
- func (t *Script) Run(name string, args ...string)
- func (t *Script) RunCmd(cmd ...*exec.Cmd)
- func (t *Script) SetLogWriter(w io.Writer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToLines ¶
func Run ¶
- Run 0 or more commands. If there are more than 1 command, pipe Stdout of each command to Stdin of the next command. Any unset Stderr is set to os.Stderr Stdout of the last command is set to os.Stdout, unless it is already set If the global Trace is true, print the commands before running them.
Types ¶
type Cmd ¶
Cmd wraps 0 or more exec.Cmd and adds convenience methods for redirecting stdin, stdout in various ways.
func (*Cmd) CombineOutput ¶
CombineOutput redirects stderr to stdout. If the output is returned or redirected to a file, it includes both stdout and stderr
func (*Cmd) InputBytes ¶
InputBytes sets Cmd.Stdin to the given []byte input
func (*Cmd) InputString ¶
InputString sets Cmd.Stdin to the given string input
func (*Cmd) Run ¶
func (t *Cmd) Run()
Run runs and/or prints the command, applying any specified redirections
type ErrorHandler ¶
type ErrorHandler interface { // Add an error. Do nothing if err is nil. Add(err error) // Return true if processing should continue. Should return true if there were no errors. // May also return true if there were prior errors, but processing should continue in order to check for more errors. Continue() bool }
ErrorHandler allows a function to report errors, without returning them directly It is used for convenience in order to minimize checking error return values from function calls
type Errors ¶
type Errors struct { // The list of non-nil errors that have been passed to Add() List []error // If AlwaysContinue is true, Continue() always return true. // In that case, examine List, or HasErrors() to find out if there were errors AlwaysContinue bool // Writer is an optional io.Writer to write errors to. Writer io.Writer }
Errors implements ErrorHandler by collecting errors in a list.
type Script ¶
type Script struct { Trace bool // print exec arguments to stdout DryRun bool Errors Errors // contains filtered or unexported fields }
func (*Script) AddError ¶
- Check if the argument is an error, or whether the script already has an error. If the argument is an error and it is the first error encountered, it becomes the script's error. Return true if the script has an error, either the given error or a previous one.