Documentation
¶
Index ¶
- func PrettyCommand(name string, args ...string) string
- func RunCommandOutputToFileFunc(cmd Cmd, path string) func() error
- type Cmd
- type Cmder
- type LocalCmd
- func (cmd *LocalCmd) Output() []byte
- 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, it returns a pretty printed command that could be pasted into a shell
func RunCommandOutputToFileFunc ¶
RunCommandOutputToFileFunc returns a func that runs the given Cmd pipes its stdout to the file specified. If the file does not exist on the host, it will be created
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
}
Cmd abstracts over running a command somewhere
type LocalCmd ¶
LocalCmd wraps os/exec.Cmd, implementing the cmdutils.Cmd interface
func (*LocalCmd) Output ¶ added in v1.18.0
Output returns the output of the command If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) Run ¶
Run runs the command If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) Start ¶ added in v1.18.0
Start starts the command but doesn't block If the returned error is non-nil, it should be of type *RunError
func (*LocalCmd) Wait ¶ added in v1.18.0
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