shell

package module
v0.0.0-...-684185a Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: GPL-3.0 Imports: 6 Imported by: 5 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

shell

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bkgd

func Bkgd() func(*command)

Bkgd is an Option to make the command run in the background

func Cancel

func Cancel(stop <-chan struct{}) func(*command)

Cancel is an Option to provide a channel whose writing to, or closing, will indicate that the command should stop

Types

type Option

type Option func(s *command)

Option is a function that modifies the given shell command

func Context

func Context(ctx context.Context) Option

Context is an Option to set a context on the command that will interrupt the command if the context is done. Only the last call to this function will be taken into account.

func Env

func Env(values []string) Option

Env is an Option to modify the shell command's execution environment. Multiple calls to this function will be taken into account, with all values passed appended into a single slice.

func Timeout

func Timeout(d time.Duration) Option

Timeout is an Option to provide a timed shell command. Only the last call to this funcion will be taken into account. By default, commands do not timeout.

type Output

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

Output is a structure to wrap the shell command output stream

func (*Output) Empty

func (o *Output) Empty() bool

Empty checks if there is any output

func (*Output) Lines

func (o *Output) Lines() []string

Lines returns the output as newline split list of lines

func (*Output) Text

func (o *Output) Text() string

Text returns the output as a single string

type Result

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

Result is the wrapper

func Run

func Run(command string, options ...Option) *Result

Run executes the command and returns a Result object. The command can be configured via one or more Option functions.

func (*Result) Canceled

func (r *Result) Canceled() bool

Canceled indicates if the command Context was canceled

func (*Result) CrashReason

func (r *Result) CrashReason() string

CrashReason returns the cause of the crash, or empty string if there was no crash

func (*Result) Crashed

func (r *Result) Crashed() bool

Crashed indicates if the command crashed

func (*Result) Duration

func (r *Result) Duration() float64

Duration indicates for how long the command ran

func (*Result) Err

func (r *Result) Err() error

Err returns an eventual error from running the command

func (*Result) ExitCode

func (r *Result) ExitCode() int

ExitCode returns the exit code of the process

func (*Result) IsError

func (r *Result) IsError() bool

IsError indicates if any error occured in preparing or executing the shell command. This will return false if the command ran ok, but just had a non-zero exit code.

func (*Result) IsReady

func (r *Result) IsReady() bool

IsReady returns a bool indicating if the command is done, and the Result object useable

func (*Result) PID

func (r *Result) PID() int

PID returns the process PID of the command

func (*Result) Ready

func (r *Result) Ready() <-chan struct{}

Ready returns a channel to indicate if the command is done

func (*Result) Stderr

func (r *Result) Stderr() *Output

Stderr returns an Output object wrapping the latest lines from the stderr stream

func (*Result) Stdout

func (r *Result) Stdout() *Output

Stdout returns an Output object wrapping the latest lines from the stdout stream

func (*Result) TimedOut

func (r *Result) TimedOut() bool

TimedOut indicates if the command Context timed out

Jump to

Keyboard shortcuts

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