shell

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalShell

type LocalShell struct {
	CatchStdout    *bool
	SuppressStdout *bool
}

func NewLocalShellWithOpts

func NewLocalShellWithOpts(opts ...Opt) *LocalShell

func (*LocalShell) CatchOutput

func (c *LocalShell) CatchOutput() bool

func (*LocalShell) Execute

func (c *LocalShell) Execute(name string, arg ...string) ([]byte, error)

func (*LocalShell) ExecuteWithOptions

func (c *LocalShell) ExecuteWithOptions(name string, args []string, opts ...Opt) ([]byte, error)

func (*LocalShell) ExitCodeOfCommand

func (c *LocalShell) ExitCodeOfCommand(command string) int

ExitCodeOfCommand runs a command and returns its exit code.

func (*LocalShell) Pipeline

func (c *LocalShell) Pipeline(cmds ...*exec.Cmd) (pipeLineOutput, collectedStandardError []byte, pipeLineError error)

Pipeline runs cmds piped after each other.

func (*LocalShell) Reset

func (c *LocalShell) Reset()

func (*LocalShell) RunCommand

func (c *LocalShell) RunCommand(args []string, opts ...Opt) ([]byte, error)

RunCommand is going to run a command depending on the caller's operating system.

func (*LocalShell) SuppressOutput

func (c *LocalShell) SuppressOutput() bool

type MockShell

type MockShell struct {
	Output      []byte
	Err         error
	LastCommand string
}

func NewMockShell

func NewMockShell(cmd string, output []byte, err error) *MockShell

func (*MockShell) Execute

func (c *MockShell) Execute(name string, args ...string) ([]byte, error)

func (*MockShell) ExecuteWithOptions

func (c *MockShell) ExecuteWithOptions(name string, args []string, opts ...Opt) ([]byte, error)

func (*MockShell) ExitCodeOfCommand

func (c *MockShell) ExitCodeOfCommand(command string) int

ExitCodeOfCommand runs a command and returns its exit code.

func (*MockShell) Pipeline

func (c *MockShell) Pipeline(cmds ...*exec.Cmd) (pipeLineOutput, collectedStandardError []byte, pipeLineError error)

Pipeline runs cmds piped after each other.

func (*MockShell) RunCommand

func (c *MockShell) RunCommand(args []string, opts ...Opt) ([]byte, error)

RunCommand is going to run a command in a shell depending on the caller's operating system.

type Opt

type Opt func(shell *LocalShell)

func WithCatchOutput

func WithCatchOutput(b bool) Opt

func WithSuppressOutput

func WithSuppressOutput(b bool) Opt

type Shell

type Shell interface {
	Execute(name string, args ...string) (output []byte, err error)
	ExecuteWithOptions(name string, args []string, opts ...Opt) (output []byte, err error)
	Pipeline(cmds ...*exec.Cmd) (pipeLineOutput, collectedStandardError []byte, pipeLineError error)
	RunCommand(args []string, opts ...Opt) (output []byte, err error)
	ExitCodeOfCommand(command string) int
}

Jump to

Keyboard shortcuts

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