Documentation ¶
Index ¶
- Variables
- type Option
- type Subprocess
- func (s *Subprocess) Exec() error
- func (s *Subprocess) ExecAsync() chan error
- func (s *Subprocess) ExitCode() int
- func (s *Subprocess) IsFinished() bool
- func (s *Subprocess) Stderr() []byte
- func (s *Subprocess) StderrText() string
- func (s *Subprocess) Stdout() []byte
- func (s *Subprocess) StdoutText() string
Constants ¶
This section is empty.
Variables ¶
var ( // Arg adds sanitized argument to command. Args = func(args ...string) Option { return func(s *Subprocess) { for _, arg := range args { s.args = append(s.args, arg) } } } // Arg adds sanitized argument to command. Arg = func(arg string) Option { return func(s *Subprocess) { s.args = append(s.args, arg) } } // Context determines where the subprocess will be executed. // A relative or absolute path may be provided. Context = func(path string) Option { return func(s *Subprocess) { s.context = path } } // Silent hides all output from the subprocess. Silent Option = func(s *Subprocess) { s.hideStdout = true s.hideStderr = true } // HideStdout hides the stdout output of the subprocess. HideStdout Option = func(s *Subprocess) { s.hideStdout = true } // HideStderr hides the stderr output of the subprocess. HideStderr Option = func(s *Subprocess) { s.hideStderr = true } // Shell determines whether the command will directly be run in the shell // without parameter sanitization. // // Only applicable for darwin or linux based systems. Windows subprocesses // are always executed in the Powershell from the CMD prompt. Shell Option = func(s *Subprocess) { s.shell = true } CatchError Option = func(s *Subprocess) { s.catchError = true } )
Subprocess options.
var (
ErrUngracefulExit = errors.New("exited ungracefully with a non 0 exit code")
)
Functions ¶
This section is empty.
Types ¶
type Subprocess ¶
type Subprocess struct {
// contains filtered or unexported fields
}
Subprocess represents a monitored process executed by the application.
func New ¶
func New(cmd string, opts ...Option) *Subprocess
New creates a new Subprocess with the default exit code of 1.
func (*Subprocess) ExecAsync ¶
func (s *Subprocess) ExecAsync() chan error
ExecAsync starts the subprocess asynchronously.
Returns a channel that closes once the result is finished.
func (*Subprocess) ExitCode ¶
func (s *Subprocess) ExitCode() int
ExitCode returns the exit code of the subprocess. If the process was terminated by a signal or has not finished.
func (*Subprocess) IsFinished ¶
func (s *Subprocess) IsFinished() bool
IsFinished returns true if the process has finished.
func (*Subprocess) Stderr ¶
func (s *Subprocess) Stderr() []byte
Stderr returns the bytes that the process has sent to stderr.
func (*Subprocess) StderrText ¶
func (s *Subprocess) StderrText() string
StderrText returns the bytes that the process has sent to stderr. The bytes are encoded in a new string.
func (*Subprocess) Stdout ¶
func (s *Subprocess) Stdout() []byte
Stdout returns the bytes that the process has sent to stdout.
func (*Subprocess) StdoutText ¶
func (s *Subprocess) StdoutText() string
StdoutText returns the bytes that the process has sent to stdout. The bytes are encoded in a new string.