command

package
v1.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd(command string, args []string) *exec.Cmd

func CommandHelperProcess added in v1.10.0

func CommandHelperProcess(t *testing.T)

func Mock

func Mock(f CommandFunc)

Enables mocking of the underlying ExecCommand command (defaults to exec.Command) and no-ops the OptionApplier function so they have no effect.

func MockExecCommand

func MockExecCommand(stdout io.Writer, stderr io.Writer) func(command string, args []string) *exec.Cmd

func MockExecCommands added in v1.10.0

func MockExecCommands(t *testing.T, commands []MockCommand) func()

func Restore

func Restore()

Restores the default ExecCommand and OptionApplier. Should be used via `defer` after `Mock` is called.

Types

type ApplyOptionFunc

type ApplyOptionFunc func(option CommandOption, cmd *exec.Cmd)
var OptionApplier ApplyOptionFunc = applyOption

type Command

type Command struct {
	// contains filtered or unexported fields
}

func WithOptions

func WithOptions(options ...CommandOption) *Command

func (*Command) Cmd

func (c *Command) Cmd(command string, args []string) *exec.Cmd

type CommandFunc

type CommandFunc func(command string, args []string) *exec.Cmd
var ExecCommand CommandFunc = execCommand

type CommandOption

type CommandOption func(*exec.Cmd)

func WithLogging

func WithLogging(ui cli.Ui) CommandOption

func WithTermOutput

func WithTermOutput() CommandOption

func WithUiOutput

func WithUiOutput(ui cli.Ui) CommandOption

type MockCommand added in v1.10.0

type MockCommand struct {
	Command  string   `json:"command"`
	Args     []string `json:"args"`
	Output   string   `json:"output"`
	ExitCode int      `json:"exit_code"`
}

type UiErrorWriter

type UiErrorWriter struct {
	Ui cli.Ui
}

func (*UiErrorWriter) Write

func (w *UiErrorWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL