exec

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args

func Args(args ...string) func(*exec.Cmd) error

Args allows you to define the arguments sent to the command to be run

func Cmd

func Cmd(cmd string, decorators ...func(*exec.Cmd) error) (*exec.Cmd, error)

Cmd provides a fluent, decorator based API for os/exec. Eg: Cmd("ping", Args("-c", "4", "1.1.1.1"))

func Cwd

func Cwd(dir string) func(*exec.Cmd) error

Cwd allows you to configure the working directory of the command to be run

func Env

func Env(env map[string]string) func(*exec.Cmd) error

Env allows you to set the exact environment in which the command will be run

func EnvCombined

func EnvCombined(env map[string]string) func(*exec.Cmd) error

EnvCombined will add the variables you provide to the existing environment

func Pipe

func Pipe(cmds ...*exec.Cmd) error

Pipe will send the output of the first command to the input of the second and so on.

func PipeBuffered

func PipeBuffered(cmds ...*exec.Cmd) (stdOutBuf, stdErrBuf []byte, err error)

PipeBuffered will buffer all StdOut and StdErr, returning the buffers. This is useful when you wish to parse the results of a pipe.

func PipePrefixed

func PipePrefixed(prefix string, cmds ...*exec.Cmd) error

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 Run

func Run(cmd string, args ...string) func() error

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")

NOTE: A closure is returned thus making for nicer syntax when used with run.Serial/Parallel functions. If using standalone you will need to invoke the returned closure.

func RunBuffered

func RunBuffered(cmd string, args ...string) (stdOutBuf, stdErrBuf string, 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")

func RunBufferedCmd

func RunBufferedCmd(cmd *exec.Cmd) (stdOutBuf, stdErrBuf []byte, err error)

RunBufferedCmd will buffer all StdOut and StdErr, returning the buffers. This is useful when you wish to parse the results of a command.

func RunPrefixed

func RunPrefixed(prefix, cmd string, args ...string) func() error

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")

NOTE: A closure is returned thus making for nicer syntax when used with run.Serial/Parallel functions. If using standalone you will need to invoke the returned closure.

func RunPrefixedCmd

func RunPrefixedCmd(prefix string, cmd *exec.Cmd) error

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 SetErr

func SetErr(err io.Writer) func(*exec.Cmd) error

SetErr allows you to set a custom StdErr stream

func SetIn

func SetIn(in io.Reader) func(*exec.Cmd) error

SetIn allows you to set a custom StdIn stream

func SetOut

func SetOut(out io.Writer) func(*exec.Cmd) error

SetOut allows you to set a custom StdOut stream

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL