exec

package
v2.0.0-...-af3797a Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

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

Cmd struct is a wrapper of exec.Cmd

func NewCmd

func NewCmd(cmd *exec.Cmd) *Cmd

NewCmd return a wa

func (*Cmd) CombinedOutput

func (c *Cmd) CombinedOutput() ([]byte, error)

CombinedOutput is a wrapper of exec.Cmd CombinedOutput method

func (*Cmd) Environ

func (c *Cmd) Environ() []string

Environ is a wrapper of exec.Cmd Environ method

func (*Cmd) Output

func (c *Cmd) Output() ([]byte, error)

Output is a wrapper of exec.Cmd Output method

func (*Cmd) Run

func (c *Cmd) Run() error

Run is a wrapper of exec.Cmd Run method

func (*Cmd) Start

func (c *Cmd) Start() error

Start is a wrapper of exec.Cmd Start method

func (*Cmd) StderrPipe

func (c *Cmd) StderrPipe() (io.ReadCloser, error)

StderrPipe is a wrapper of exec.Cmd StderrPipe method

func (*Cmd) StdinPipe

func (c *Cmd) StdinPipe() (io.WriteCloser, error)

StdinPipe is a wrapper of exec.Cmd StdinPipe method

func (*Cmd) StdoutPipe

func (c *Cmd) StdoutPipe() (io.ReadCloser, error)

StdoutPipe is a wrapper of exec.Cmd StdoutPipe method

func (*Cmd) String

func (c *Cmd) String() string

String is a wrapper of exec.Cmd String method

func (*Cmd) Wait

func (c *Cmd) Wait() error

Wait is a wrapper of exec.Cmd Wait method

type Cmder

type Cmder interface {
	CombinedOutput() ([]byte, error)
	Environ() []string
	Output() ([]byte, error)
	Run() error
	Start() error
	StderrPipe() (io.ReadCloser, error)
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.ReadCloser, error)
	String() string
	Wait() error
}

Cmder is an interface to run a command

type Exec

type Exec struct{}

Exec struct wrapps the OS Exec package

func NewExec

func NewExec() *Exec

func (*Exec) Command

func (e *Exec) Command(name string, arg ...string) Cmder

Command is a wrapper of exec.Command

func (*Exec) CommandContext

func (e *Exec) CommandContext(ctx context.Context, name string, arg ...string) Cmder

CommandContext is a wrapper of exec.CommandContext

type MockCmd

type MockCmd struct {
	mock.Mock
}

MockCmd struct is a mock of exec.Cmd

func NewMockCmd

func NewMockCmd() *MockCmd

NewMockCmd return a Mock for exec.Cmd

func (*MockCmd) CombinedOutput

func (c *MockCmd) CombinedOutput() ([]byte, error)

CombinedOutput is a mock of exec.Cmd CombinedOutput method

func (*MockCmd) Environ

func (c *MockCmd) Environ() []string

Environ is a mock of exec.Cmd Environ method

func (*MockCmd) Output

func (c *MockCmd) Output() ([]byte, error)

Output is a mock of exec.Cmd Output method

func (*MockCmd) Run

func (c *MockCmd) Run() error

Run is a mock of exec.Cmd Run method

func (*MockCmd) Start

func (c *MockCmd) Start() error

Start is a mock of exec.Cmd Start method

func (*MockCmd) StderrPipe

func (c *MockCmd) StderrPipe() (io.ReadCloser, error)

StderrPipe is a mock of exec.Cmd StderrPipe method

func (*MockCmd) StdinPipe

func (c *MockCmd) StdinPipe() (io.WriteCloser, error)

StdinPipe is a mock of exec.Cmd StdinPipe method

func (*MockCmd) StdoutPipe

func (c *MockCmd) StdoutPipe() (io.ReadCloser, error)

StdoutPipe is a mock of exec.Cmd StdoutPipe method

func (*MockCmd) String

func (c *MockCmd) String() string

String is a mock of exec.Cmd String method

func (*MockCmd) Wait

func (c *MockCmd) Wait() error

Wait is a mock of exec.Cmd Wait method

type MockExec

type MockExec struct {
	mock.Mock
}

MockExec struct is wrapper of os.Exec that enable you to mock os.Cmd

func NewMockExec

func NewMockExec() *MockExec

NewMockExec returns a MockExec to mock to Cmd

func (*MockExec) Command

func (e *MockExec) Command(name string, arg ...string) Cmder

Command is a wrapper of exec.Command

func (*MockExec) CommandContext

func (e *MockExec) CommandContext(ctx context.Context, name string, arg ...string) Cmder

CommandContext is a wrapper of exec.CommandContext

Jump to

Keyboard shortcuts

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