Documentation
¶
Overview ¶
Package binwrapper provides an executable wrapper with convenient methods for running command line tools and capturing their output. Inspired by and partially ported from npm package bin-wrapper: https://github.com/kevva/bin-wrapper
Index ¶
- type BinWrapper
- func (b *BinWrapper) Arg(name string, values ...string) *BinWrapper
- func (b *BinWrapper) Args() []string
- func (b *BinWrapper) AutoExe() *BinWrapper
- func (b *BinWrapper) CombinedOutput() []byte
- func (b *BinWrapper) Debug() *BinWrapper
- func (b *BinWrapper) Dest(dest string) *BinWrapper
- func (b *BinWrapper) Dir(dir string) *BinWrapper
- func (b *BinWrapper) Env(env []string) *BinWrapper
- func (b *BinWrapper) ExecPath(execPath string) *BinWrapper
- func (b *BinWrapper) Kill() error
- func (b *BinWrapper) Path() string
- func (b *BinWrapper) Reset() *BinWrapper
- func (b *BinWrapper) Run(arg ...string) error
- func (b *BinWrapper) SetStdOut(writer io.Writer) *BinWrapper
- func (b *BinWrapper) StdErr() []byte
- func (b *BinWrapper) StdIn(reader io.Reader) *BinWrapper
- func (b *BinWrapper) StdOut() []byte
- func (b *BinWrapper) Timeout(timeout time.Duration) *BinWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinWrapper ¶
type BinWrapper struct {
// contains filtered or unexported fields
}
BinWrapper wraps executable and provides convenient methods to interact with
func (*BinWrapper) Arg ¶
func (b *BinWrapper) Arg(name string, values ...string) *BinWrapper
Arg adds command line argument to run the binary with.
func (*BinWrapper) Args ¶
func (b *BinWrapper) Args() []string
Args returns arguments were added with Arg method
func (*BinWrapper) AutoExe ¶
func (b *BinWrapper) AutoExe() *BinWrapper
AutoExe adds .exe extension for windows executable path
func (*BinWrapper) CombinedOutput ¶
func (b *BinWrapper) CombinedOutput() []byte
CombinedOutput returns combined executable's stdout and stderr
func (*BinWrapper) Dest ¶
func (b *BinWrapper) Dest(dest string) *BinWrapper
Dest accepts a path which the binary is located in
func (*BinWrapper) Dir ¶
func (b *BinWrapper) Dir(dir string) *BinWrapper
Dir specifies the working directory of the executable. If Dir is empty, Run uses the calling process's current directory.
func (*BinWrapper) Env ¶
func (b *BinWrapper) Env(env []string) *BinWrapper
Env specifies the environment of the executable. If Env is nil, Run uses the current process's environment. Elements of env should be in form: "ENV_VARIABLE_NAME=value"
func (*BinWrapper) ExecPath ¶
func (b *BinWrapper) ExecPath(execPath string) *BinWrapper
ExecPath define a file to use as the binary
func (*BinWrapper) Path ¶
func (b *BinWrapper) Path() string
Path returns the full path to the binary
func (*BinWrapper) Reset ¶
func (b *BinWrapper) Reset() *BinWrapper
Reset removes arguments, stdin, stdout writer, env, and clears captured stdout/stderr
func (*BinWrapper) Run ¶
func (b *BinWrapper) Run(arg ...string) error
Run runs the binary with provided arg list. Arg list is appended to args set through Arg method Returns context.DeadlineExceeded in case of timeout
func (*BinWrapper) SetStdOut ¶
func (b *BinWrapper) SetStdOut(writer io.Writer) *BinWrapper
SetStdOut set writer to write executable's stdout
func (*BinWrapper) StdErr ¶
func (b *BinWrapper) StdErr() []byte
StdErr returns the executable's stderr after Run was called
func (*BinWrapper) StdIn ¶
func (b *BinWrapper) StdIn(reader io.Reader) *BinWrapper
StdIn sets reader to read executable's stdin from
func (*BinWrapper) StdOut ¶
func (b *BinWrapper) StdOut() []byte
StdOut returns the binary's stdout after Run was called
func (*BinWrapper) Timeout ¶
func (b *BinWrapper) Timeout(timeout time.Duration) *BinWrapper
Timeout sets timeout for the command. By default it's 0 (binary will run till end).