shellz

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLogf is the default implementation of Logf.
	DefaultLogf = func(cmd string, params ...interface{}) {
		fmt.Println(append([]interface{}{"[shell]", cmd}, params...)...)
	}
)

Functions

This section is empty.

Types

type Command

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

Command describes a command to be spawned in a shell.

func NewCommand

func NewCommand(cmd string, initialParams ...interface{}) *Command

NewCommand creates a new Command.

func (*Command) AddParams

func (c *Command) AddParams(params ...interface{}) *Command

AddParams appends the given params to the command.

func (*Command) AddParamsString

func (c *Command) AddParamsString(params ...string) *Command

AddParamsString appends the given params to the command.

func (*Command) MustExec added in v1.1.0

func (c *Command) MustExec()

MustExec replaces the current process using syscall.Exec with the Command. Note that: - It never returns. - It ignores stdin/stdout/stderr settings. - Unlike MustRun/MustOutput, it coerces params to strings using fmt.Sprintf.

func (*Command) MustOutput

func (c *Command) MustOutput() string

MustOutput is like Output but panics on error.

func (*Command) MustRun

func (c *Command) MustRun()

MustRun is like Run but panics on error.

func (*Command) Output

func (c *Command) Output() (string, error)

Output runs the command and returns its combined output as string.

func (*Command) Run

func (c *Command) Run() error

Run runs the command.

func (*Command) SetDir

func (c *Command) SetDir(dir string) *Command

SetDir sets the command working directory.

func (*Command) SetEnv

func (c *Command) SetEnv(key, value string) *Command

SetEnv sets an environment variable.

func (*Command) SetEnvMap

func (c *Command) SetEnvMap(m map[string]string) *Command

SetEnvMap sets a map of environment variable.

func (*Command) SetLogf

func (c *Command) SetLogf(logf Logf) *Command

SetLogf overrides DefaultLogf for this command. Set to nil to skip logging.

func (*Command) SetStderr

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

SetStderr sets the command standard error.

func (*Command) SetStdin

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

SetStdin sets the command standard input.

func (*Command) SetStdout

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

SetStdout sets the command standard output.

type Logf

type Logf func(string, ...interface{})

Logf describes a function that echoes the details of the command being run.

Jump to

Keyboard shortcuts

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