Documentation
¶
Index ¶
- Constants
- Variables
- func Find(name string, options *WhichOptions) (string, error)
- func Register(name string, exe *Executable)
- func SetEnvLike(e EnvLike)
- func SetLogger(f func(cmd *Cmd))
- func Which(command string) (string, bool)
- func WhichFirst(command string, options *WhichOptions) (string, bool)
- type Cmd
- func (c *Cmd) AppendArgs(args ...string) *Cmd
- func (c *Cmd) AppendEnv(env ...string) *Cmd
- func (c *Cmd) DisableLogger()
- func (c *Cmd) Output() (*Result, error)
- func (c *Cmd) Pipe(subcommands ...*Cmd) *Pipeline
- func (c *Cmd) PipeCommand(subcommands ...string) *Pipeline
- func (c *Cmd) PrependArgs(args ...string) *Cmd
- func (c *Cmd) PrependEnv(env ...string) *Cmd
- func (c *Cmd) Quiet() (*Result, error)
- func (c *Cmd) Run() (*Result, error)
- func (c *Cmd) SetLogger(f func(cmd *Cmd))
- func (c *Cmd) Start() error
- func (c *Cmd) Wait() error
- func (c *Cmd) WithArgs(args ...string) *Cmd
- func (c *Cmd) WithCwd(dir string) *Cmd
- func (c *Cmd) WithEnv(env ...string) *Cmd
- func (c *Cmd) WithEnvMap(env map[string]string) *Cmd
- func (c *Cmd) WithStderr(stderr io.Writer) *Cmd
- func (c *Cmd) WithStdin(stdin io.Reader) *Cmd
- func (c *Cmd) WithStdio(stdin, stdout, stderr int) *Cmd
- func (c *Cmd) WithStdout(stdout io.Writer) *Cmd
- type EnvLike
- type Executable
- type ExecutableRegistry
- func (r *ExecutableRegistry) Find(name string, options *WhichOptions) (string, error)
- func (r *ExecutableRegistry) Get(name string) (*Executable, bool)
- func (r *ExecutableRegistry) Has(name string) bool
- func (r *ExecutableRegistry) Register(name string, exe *Executable)
- func (r *ExecutableRegistry) Set(name string, exe *Executable)
- type Pipeline
- type Result
- func (o *Result) ErrorJson() (interface{}, error)
- func (o *Result) ErrorLines() []string
- func (o *Result) ErrorText() string
- func (o *Result) IsOk() bool
- func (o *Result) Json() (interface{}, error)
- func (o *Result) Lines() []string
- func (o *Result) Text() string
- func (o *Result) ToError() error
- func (o *Result) ToErrorIf(f func(o *Result) bool) error
- func (o *Result) Validate() (bool, error)
- func (o *Result) ValidateWith(cb func(o *Result) (bool, error)) (bool, error)
- type WhichOptions
Constants ¶
View Source
const ( STDIO_INHERIT = 0 STDIO_PIPED = 1 STDIO_NULL = 2 )
View Source
const (
EOL = "\n" // POSIX line endings
)
Variables ¶
View Source
var Registry = &ExecutableRegistry{data: make(map[string]Executable)}
Functions ¶
func Register ¶
func Register(name string, exe *Executable)
func SetEnvLike ¶
func SetEnvLike(e EnvLike)
func WhichFirst ¶
func WhichFirst(command string, options *WhichOptions) (string, bool)
Types ¶
type Cmd ¶
func Command ¶
Command parses the command and arguments and returns a new Cmd with the parsed command and arguments Example:
Command("echo hello world")
Command("echo 'hello world'")
func (*Cmd) AppendArgs ¶
func (*Cmd) DisableLogger ¶
func (c *Cmd) DisableLogger()
func (*Cmd) Output ¶
Runs the command and captures the PsOutput PsOutputs are captured from the current process and are not inherited
func (*Cmd) PipeCommand ¶
func (*Cmd) PrependArgs ¶
func (*Cmd) PrependEnv ¶
type EnvLike ¶
type EnvLike interface {
Get(key string) string
Expand(s string) (string, error)
Set(key, value string)
SplitPath() []string
}
func GetEnvLike ¶
func GetEnvLike() EnvLike
type Executable ¶
type ExecutableRegistry ¶
type ExecutableRegistry struct {
// contains filtered or unexported fields
}
func (*ExecutableRegistry) Find ¶
func (r *ExecutableRegistry) Find(name string, options *WhichOptions) (string, error)
func (*ExecutableRegistry) Get ¶
func (r *ExecutableRegistry) Get(name string) (*Executable, bool)
func (*ExecutableRegistry) Has ¶
func (r *ExecutableRegistry) Has(name string) bool
func (*ExecutableRegistry) Register ¶
func (r *ExecutableRegistry) Register(name string, exe *Executable)
func (*ExecutableRegistry) Set ¶
func (r *ExecutableRegistry) Set(name string, exe *Executable)
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
func (*Pipeline) PipeCommand ¶
type Result ¶
type Result struct {
Stdout []byte
Stderr []byte
Code int
FileName string
Args []string
StartedAt time.Time
EndedAt time.Time
TempFile *string
}
func (*Result) ErrorLines ¶
type WhichOptions ¶
Click to show internal directories.
Click to hide internal directories.