Documentation
¶
Overview ¶
Package goexec is a fluent decorator based API for os/exec
Index ¶
- func Args(args ...string) func(*exec.Cmd) error
- func Cmd(cmd string, decorators ...func(*exec.Cmd) error) (c *exec.Cmd, err error)
- func Cwd(dir string) func(*exec.Cmd) error
- func Env(env map[string]string) func(*exec.Cmd) error
- func EnvCombined(env map[string]string) func(*exec.Cmd) error
- func MustCmd(cmd string, decorators ...func(*exec.Cmd) error) *exec.Cmd
- func MustPipe(cmds ...*exec.Cmd)
- func MustPipePrefixed(prefix string, cmds ...*exec.Cmd)
- func MustRun(cmd string, args ...string)
- func MustRunPrefixed(prefix, cmd string, args ...string)
- func MustRunPrefixedCmd(prefix string, cmd *exec.Cmd)
- func Pipe(cmds ...*exec.Cmd) (err error)
- func PipeAsync(cmds ...*exec.Cmd) *task.Task
- func PipeBufferedAsync(cmds ...*exec.Cmd) *task.Task
- func PipePrefixed(prefix string, cmds ...*exec.Cmd) (err error)
- func PipePrefixedAsync(prefix string, cmds ...*exec.Cmd) *task.Task
- func Run(cmd string, args ...string) (err error)
- func RunAsync(cmd string, args ...string) *task.Task
- func RunBufferedAsync(cmd string, args ...string) *task.Task
- func RunBufferedCmdAsync(cmd *exec.Cmd) *task.Task
- func RunPrefixed(prefix, cmd string, args ...string) (err error)
- func RunPrefixedAsync(prefix, cmd string, args ...string) *task.Task
- func RunPrefixedCmd(prefix string, cmd *exec.Cmd) (err error)
- func RunPrefixedCmdAsync(prefix string, cmd *exec.Cmd) *task.Task
- func SetErr(err io.Writer) func(*exec.Cmd) error
- func SetIn(in io.Reader) func(*exec.Cmd) error
- func SetOut(out io.Writer) func(*exec.Cmd) error
- type StdBytes
- type StdStrings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmd ¶
Cmd provides a fluent, decorator based API for os/exec.
Cmd("ping", Args("-c", "4", "1.1.1.1"))
func EnvCombined ¶
EnvCombined will add the variables you provide to the existing environment
func MustPipePrefixed ¶
MustPipePrefixed does the same as PipePrefixed but panics if an error is encountered.
func MustRunPrefixed ¶
MustRunPrefixed does the same as RunPrefixed but panics if an error is encountered.
func MustRunPrefixedCmd ¶
MustRunPrefixedCmd does the same as RunPrefixedCmd but panics if an error is encountered.
func PipeBufferedAsync ¶
PipeBufferedAsync does the same as PipeBuffered but does so asynchronously.
func PipePrefixed ¶
PipePrefixed will prefix all StdOut and StdErr with given prefix. This is useful when running many pipes concurrently, output will look similar to docker-compose.
func PipePrefixedAsync ¶
PipePrefixedAsync does the same as PipePrefixed but does so asynchronously.
func Run ¶
Run is a convenience function for simple cases.
Instead of:
Cmd("ping", Args("-c", "4", "8.8.8.8")).Run()
You might write:
Run("ping", "-c", "4", "8.8.8.8")
func RunBufferedAsync ¶
RunBufferedAsync does the same as RunBuffered but does so asynchronously.
func RunBufferedCmdAsync ¶
RunBufferedCmdAsync does the same as RunBufferedCmd but does so asynchronously.
func RunPrefixed ¶
RunPrefixed is a convenience function for simple cases.
Instead of:
RunPrefixedCmd("foo", Cmd("ping", Args("-c", "4", "8.8.8.8")))
You might write:
RunPrefixed("foo", "ping", "-c", "4", "8.8.8.8")
func RunPrefixedAsync ¶
RunPrefixedAsync does the same as RunPrefixed but does so asynchronously.
func RunPrefixedCmd ¶
RunPrefixedCmd will prefix all StdOut and StdErr with given prefix. This is useful when running many commands concurrently, output will look similar to docker-compose.
func RunPrefixedCmdAsync ¶
RunPrefixedCmdAsync does the same as RunPrefixedCmd but does so asynchronously.
Types ¶
type StdBytes ¶
StdBytes represents the buffered output from a process.
func MustPipeBuffered ¶
MustPipeBuffered does the same as PipeBuffered but panics if an error is encountered.
func MustRunBufferedCmd ¶
MustRunBufferedCmd does the same as RunBufferedCmd but panics if an error is encountered.
func PipeBuffered ¶
PipeBuffered will buffer all StdOut and StdErr, returning the buffers. This is useful when you wish to parse the results of a pipe.
type StdStrings ¶
StdStrings represents the buffered output from a process after having been casted to strings.
func MustRunBuffered ¶
func MustRunBuffered(cmd string, args ...string) *StdStrings
MustRunBuffered does the same as RunBuffered but panics if an error is encountered.
func RunBuffered ¶
func RunBuffered(cmd string, args ...string) (out *StdStrings, err error)
RunBuffered is a convenience function for simple cases.
Instead of:
RunBufferedCmd(Cmd("ping", Args("-c", "4", "8.8.8.8")))
You might write:
RunBuffered("ping", "-c", "4", "8.8.8.8")
NOTE: `RunBuffered()` returns stdOut and stdErr as strings if you want the untouched byte arrays you could use `RunBufferedCmd()` instead.