Documentation
¶
Index ¶
- func PrettyCommand(quoteAll bool, name string, args ...string) string
- type Cmd
- type Cmder
- type LocalCmd
- func (cmd *LocalCmd) Output() []byte
- func (cmd *LocalCmd) PrettyCommand() string
- func (cmd *LocalCmd) Run() *RunError
- func (cmd *LocalCmd) Start() *RunError
- func (cmd *LocalCmd) Wait() *RunError
- func (cmd *LocalCmd) WithEnv(env ...string) Cmd
- func (cmd *LocalCmd) WithStderr(w io.Writer) Cmd
- func (cmd *LocalCmd) WithStdin(r io.Reader) Cmd
- func (cmd *LocalCmd) WithStdout(w io.Writer) Cmd
- type LocalCmder
- type RunError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrettyCommand ¶
PrettyCommand takes arguments identical to Cmder.Command, with a leading quote flag. Behavior: - quoteAll == true: quote all tokens (command and all args) - quoteAll == false: print tokens unquoted, but quote any arg that contains whitespace It returns a pretty printed command that could be pasted into a shell.
Types ¶
type Cmd ¶
type Cmd interface {
// Run executes the command (like os/exec.Cmd.Run)
// It returns a *RunError if there is any error, nil otherwise
Run() *RunError
// Start starts the command but doesn't block
// If the returned error is non-nil, it should be of type *RunError
Start() *RunError
// Wait waits for the command to finish
// If the returned error is non-nil, it should be of type *RunError
Wait() *RunError
// Output returns the output of the executed command
Output() []byte
// WithEnv sets the Env variables for the Cmd
// Each entry should be of the form "key=value"
WithEnv(...string) Cmd
// WithStdin sets the io.Reader used for stdin
WithStdin(reader io.Reader) Cmd
// WithStdout sets the io.Writer used for stdout
WithStdout(io.Writer) Cmd
// WithStderr sets the io.Reader used for stderr
WithStderr(io.Writer) Cmd
PrettyCommand() string
}
Cmd abstracts over running a command somewhere
type LocalCmd ¶
LocalCmd wraps os/exec.Cmd, implementing the cmdutils.Cmd interface
func (*LocalCmd) Output ¶
Output returns the output of the command If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) PrettyCommand ¶
func (*LocalCmd) Run ¶
Run runs the command If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) Start ¶
Start starts the command but doesn't block If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) Wait ¶
Wait waits for the command to finish If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) WithStderr ¶
WithStderr sets stderr
type RunError ¶
type RunError struct {
// contains filtered or unexported fields
}
RunError represents an error running a Cmd
func (*RunError) OutputString ¶
func (*RunError) PrettyCommand ¶
PrettyCommand pretty prints the command in a way that could be pasted into a shell