Categorygithub.com/reconquest/executil-go
repositorypackage
0.0.0-20181110204642-1f5c2d67813f
Repository: https://github.com/reconquest/executil-go.git
Documentation: pkg.go.dev

# README

todo comming soon

func Run(cmd *exec.Cmd) (stdout []byte, stderr []byte, err error)

Run sets writers for stdout and stderr, starts the specified command and waits for it to complete.

The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status. Otherwise, the error is of type Error.

type Error error

Error records the actual combined output of executed command, original error and executed cmd.

type Error struct {
	// RunErr is a original occurred error.
	RunErr error
	// Cmd is a original executed command.
	Cmd *exec.Cmd
	// Output is a combined output of executing command.
	Output []byte
}

func (err *Error) Error() string

Error returns string representation of Error type.

func IsExitError(err error) bool

IsExitError check that the specified error is an error about exit status.

func GetExitStatus(err error) int

GetExitStatus returns 0 if the specified error is not about of exit status. Otherwise, will be returned actual exit status.


coverage: 100.0% of statements

github.com/kovetskiy/executil/error.go:20:      Error           100.0%
github.com/kovetskiy/executil/exit_error.go:8:  getWaitStatus   100.0%
github.com/kovetskiy/executil/exit_error.go:27: IsExitError     100.0%
github.com/kovetskiy/executil/exit_error.go:33: GetExitStatus   100.0%
github.com/kovetskiy/executil/run.go:15:        Write           100.0%
github.com/kovetskiy/executil/run.go:29:        Run             100.0%
total:                                          (statements)    100.0%
SubjectBehavior
RunReturns Stdout If Stderr Is Empty
RunReturns Stderr If Stdout Is Empty
RunReturns Stdout And Stderr If Both Not Empty
RunReturns Error If Command Failed
RunReturns Error Type Of Executil Error
RunReturns Error With Exit Status1
RunReturns Error With Exit Status2
Error.OutputIs Combined Output Of Executed Command
Error.CmdIs Actual Executed Command
Error.RunErrIs Actual Error Of Executed Command
Error->ErrorContains Of Actual Error
Error->ErrorContains Of Command Args
Error->ErrorContains Of Output If Output Is Not Empty
Error->ErrorContains Of Message With Output If Output Is Not Empty
Error->ErrorContains Of Message Without Output If Output Is Empty
IsExitErrorReturns True For Os Exit Error
IsExitErrorReturns True For Executil Error When Run Err Is Exit Error
IsExitErrorReturns False For Executil Error With Non Exec Error
IsExitErrorReturns False For Executil Error With Nil
IsExitErrorReturns False For All Errors
IsExitErrorReturns False For Nil
GetExitStatusReturns Exit Status Of Actual Error
GetExitStatusReturns Exit Status Of Executil Error With Actual Error
GetExitStatusReturns Zero For Nil
GetExitStatusReturns Zero For Executil Error With Nil
GetExitStatusReturns Zero For Executil Error With Non Exit Error
GetExitStatusReturns Zero For Non Exit Error