sh

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

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

Command is a fluent builder for executing external commands.

func Cmd

func Cmd(cmd ...string) *Command

Cmd creates a new command builder.

func (*Command) CombinedOutput

func (self *Command) CombinedOutput() ([]byte, error)

CombinedOutput runs the command and returns its combined stdout and stderr.

func (*Command) Dir

func (self *Command) Dir(dir string) *Command

Dir sets the working directory for the command.

func (*Command) Env

func (self *Command) Env(env []string) *Command

Env sets the environment for the command.

func (*Command) ExitCode

func (self *Command) ExitCode() int

ExitCode runs the command and returns its exit code. Returns -1 if the command failed to start.

func (*Command) Interactive

func (self *Command) Interactive() *Command

Interactive connects stdin, stdout, and stderr to os.Stdin, os.Stdout, and os.Stderr.

func (*Command) JustOutputLines

func (self *Command) JustOutputLines() []string

JustOutputLines runs the command and returns its stdout as a slice of lines, or an empty slice if the command fails.

func (*Command) JustOutputString

func (self *Command) JustOutputString() string

JustOutputString runs the command and returns its stdout as a trimmed string, or an empty string if the command fails.

func (*Command) MustCombinedOutput

func (self *Command) MustCombinedOutput() []byte

MustCombinedOutput runs the command and returns its combined stdout and stderr, panicking if it fails.

func (*Command) MustOutput

func (self *Command) MustOutput() []byte

MustOutput runs the command and returns its stdout, panicking if it fails.

func (*Command) MustOutputLines

func (self *Command) MustOutputLines() []string

MustOutputLines runs the command and returns its stdout as a slice of lines, panicking if it fails.

func (*Command) MustOutputString

func (self *Command) MustOutputString() string

MustOutputString runs the command and returns its stdout as a trimmed string, panicking if it fails.

func (*Command) MustRun

func (self *Command) MustRun()

MustRun runs the command and panics if it fails.

func (*Command) Output

func (self *Command) Output() ([]byte, error)

Output runs the command and returns its stdout.

func (*Command) OutputLines

func (self *Command) OutputLines() ([]string, error)

OutputLines runs the command and returns its stdout as a slice of lines.

func (*Command) OutputString

func (self *Command) OutputString() (string, error)

OutputString runs the command and returns its stdout as a trimmed string.

func (*Command) Passthrough

func (self *Command) Passthrough() *Command

Passthrough connects stdout and stderr to os.Stdout and os.Stderr.

func (*Command) Quiet

func (self *Command) Quiet() *Command

Quiet connects stdin and stderr to os.Stdin and os.Stderr, but not stdout.

func (*Command) Run

func (self *Command) Run() error

Run runs the command and returns an error if it fails.

func (*Command) Stderr

func (self *Command) Stderr(w io.Writer) *Command

Stderr sets the stderr writer for the command.

func (*Command) Stdin

func (self *Command) Stdin(r io.Reader) *Command

Stdin sets the stdin reader for the command.

func (*Command) Stdout

func (self *Command) Stdout(w io.Writer) *Command

Stdout sets the stdout writer for the command.

func (*Command) Success

func (self *Command) Success() bool

Success runs the command and returns true if it exits with code 0.

Jump to

Keyboard shortcuts

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