command

package
v1.149.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecCommand = exec.Command

ExecCommand defines how to execute os commands

Functions

This section is empty.

Types

type Command

type Command struct {
	ErrorCategoryMapping map[string][]string
	// contains filtered or unexported fields
}

Command defines the information required for executing a call to any executable

func (*Command) AppendEnv added in v1.62.0

func (c *Command) AppendEnv(env []string)

AppendEnv appends environment variables to be used for execution

func (*Command) GetExitCode added in v1.51.0

func (c *Command) GetExitCode() int

GetExitCode allows to retrieve the exit code of a command execution

func (*Command) GetStderr added in v1.124.0

func (c *Command) GetStderr() io.Writer

GetStderr Retursn the writer for stderr

func (*Command) GetStdout added in v1.124.0

func (c *Command) GetStdout() io.Writer

GetStdout Returns the writer for stdout

func (*Command) RunExecutable

func (c *Command) RunExecutable(executable string, params ...string) error

RunExecutable runs the specified executable with parameters !! While the cmd.Env is applied during command execution, it is NOT involved when the actual executable is resolved.

Thus the executable needs to be on the PATH of the current process and it is not sufficient to alter the PATH on cmd.Env.

func (*Command) RunExecutableInBackground added in v1.45.0

func (c *Command) RunExecutableInBackground(executable string, params ...string) (Execution, error)

RunExecutableInBackground runs the specified executable with parameters in the background non blocking !! While the cmd.Env is applied during command execution, it is NOT involved when the actual executable is resolved.

Thus the executable needs to be on the PATH of the current process and it is not sufficient to alter the PATH on cmd.Env.

func (*Command) RunShell

func (c *Command) RunShell(shell, script string) error

RunShell runs the specified command on the shell

func (*Command) SetDir added in v1.15.0

func (c *Command) SetDir(dir string)

SetDir sets the working directory for the execution

func (*Command) SetEnv added in v1.15.0

func (c *Command) SetEnv(env []string)

SetEnv sets explicit environment variables to be used for execution

func (*Command) Stderr

func (c *Command) Stderr(stderr io.Writer)

Stderr ..

func (*Command) Stdin added in v1.139.0

func (c *Command) Stdin(stdin io.Reader)

Stdin ..

func (*Command) Stdout

func (c *Command) Stdout(stdout io.Writer)

Stdout ..

type ExecRunner added in v1.51.0

type ExecRunner interface {
	RunExecutable(executable string, params ...string) error
	RunExecutableInBackground(executable string, params ...string) (Execution, error)
	// contains filtered or unexported methods
}

ExecRunner mock for intercepting calls to executables

type Execution added in v1.45.0

type Execution interface {
	Kill() error
	Wait() error
}

Execution references a background process which is started by RunExecutableInBackground

type ShellRunner added in v1.51.0

type ShellRunner interface {
	RunShell(shell string, command string) error
	// contains filtered or unexported methods
}

ShellRunner mock for intercepting shell calls

Jump to

Keyboard shortcuts

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