Documentation
¶
Overview ¶
Package shell allows to run commands in a shell.
Index ¶
- func GetExitCodeForRunCommandError(err error) (int, error)
- func RunCommandContext(t testing.TestingT, ctx context.Context, command *Command)
- func RunCommandContextAndGetOutput(t testing.TestingT, ctx context.Context, command *Command) string
- func RunCommandContextAndGetOutputE(t testing.TestingT, ctx context.Context, command *Command) (string, error)
- func RunCommandContextAndGetStdOut(t testing.TestingT, ctx context.Context, command *Command) string
- func RunCommandContextAndGetStdOutE(t testing.TestingT, ctx context.Context, command *Command) (string, error)
- func RunCommandContextAndGetStdOutErr(t testing.TestingT, ctx context.Context, command *Command) (stdout string, stderr string)
- func RunCommandContextAndGetStdOutErrE(t testing.TestingT, ctx context.Context, command *Command) (stdout string, stderr string, err error)
- func RunCommandContextE(t testing.TestingT, ctx context.Context, command *Command) error
- type Command
- type ErrWithCmdOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetExitCodeForRunCommandError ¶
GetExitCodeForRunCommandError tries to read the exit code for the error object returned from running a shell command. This is a bit tricky to do in a way that works across platforms.
func RunCommandContext ¶
RunCommandContext is like RunCommand but includes a context.
func RunCommandContextAndGetOutput ¶
func RunCommandContextAndGetOutput(t testing.TestingT, ctx context.Context, command *Command) string
RunCommandContextAndGetOutput is like RunCommandAndGetOutput but includes a context.
func RunCommandContextAndGetOutputE ¶
func RunCommandContextAndGetOutputE(t testing.TestingT, ctx context.Context, command *Command) (string, error)
RunCommandContextAndGetOutputE is like RunCommandAndGetOutputE but includes a context.
func RunCommandContextAndGetStdOut ¶
func RunCommandContextAndGetStdOut(t testing.TestingT, ctx context.Context, command *Command) string
RunCommandContextAndGetStdOut is like RunCommandAndGetStdOut but includes a context.
func RunCommandContextAndGetStdOutE ¶
func RunCommandContextAndGetStdOutE(t testing.TestingT, ctx context.Context, command *Command) (string, error)
RunCommandContextAndGetStdOutE is like RunCommandAndGetStdOutE but includes a context.
func RunCommandContextAndGetStdOutErr ¶
func RunCommandContextAndGetStdOutErr(t testing.TestingT, ctx context.Context, command *Command) (stdout string, stderr string)
RunCommandContextAndGetStdOutErr is like RunCommandAndGetStdOutErr but includes a context.
Types ¶
type Command ¶
type Command struct {
// Use the specified logger for the command's output. Use logger.Discard to not print the output while executing the command.
Logger *logger.Logger
Stdin io.Reader
Env map[string]string // Additional environment variables to set
Command string // The command to run
WorkingDir string // The working directory
Args []string // The args to pass to the command
}
Command is a simpler struct for defining commands than Go's built-in Cmd.
type ErrWithCmdOutput ¶
type ErrWithCmdOutput struct {
Underlying error
Output *output
}
ErrWithCmdOutput wraps an underlying error with the captured stdout and stderr from the command that produced it.
func (*ErrWithCmdOutput) Error ¶
func (e *ErrWithCmdOutput) Error() string