execx

package
v0.25.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug         = false  //nolint:gochecknoglobals // This variable is shared between all the command instances.
	LogFile       *os.File //nolint:gochecknoglobals // This variable is shared between all the command instances.
	NoTTY         = false  //nolint:gochecknoglobals // This variable is shared between all the command instances.
	ErrCmdFailed  = errors.New("command failed")
	ErrCmdTimeout = errors.New("command timed out")
)

Functions

func CombinedOutput

func CombinedOutput(cmd *Cmd) (string, error)

func CombinedOutputWithTimeout

func CombinedOutputWithTimeout(cmd *Cmd, timeout time.Duration) (string, error)

func NewErrCmdFailed

func NewErrCmdFailed(name string, args []string, err error, res *CmdLog) error

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	Log *CmdLog
}

func NewCmd

func NewCmd(name string, opts CmdOptions) *Cmd

func (*Cmd) Run

func (c *Cmd) Run() error

func (*Cmd) RunWithTimeout

func (c *Cmd) RunWithTimeout(timeout time.Duration) error

type CmdLog

type CmdLog struct {
	Out *bytes.Buffer
	Err *bytes.Buffer
}

func (CmdLog) String

func (c CmdLog) String() string

type CmdOptions

type CmdOptions struct {
	Args     []string
	Err      io.Writer
	Executor Executor
	Out      io.Writer
	WorkDir  string
}

type Executor

type Executor interface {
	Command(name string, arg ...string) *exec.Cmd
}

type FakeExecutor

type FakeExecutor struct{}

func NewFakeExecutor

func NewFakeExecutor() *FakeExecutor

func (*FakeExecutor) Command

func (*FakeExecutor) Command(name string, arg ...string) *exec.Cmd

type StdExecutor

type StdExecutor struct{}

func NewStdExecutor

func NewStdExecutor() *StdExecutor

func (*StdExecutor) Command

func (*StdExecutor) Command(name string, arg ...string) *exec.Cmd

Jump to

Keyboard shortcuts

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