github.com/reconquest/executil-go@v0.0.0-20181110204642-1f5c2d67813f/README.md (about) 1 todo comming soon 2 3 ### func Run(cmd *exec.Cmd) (stdout []byte, stderr []byte, err error) 4 5 > Run sets writers for stdout and stderr, starts the specified command and 6 > waits for it to complete. 7 > 8 > The returned error is nil if the command runs, has no problems copying stdin, 9 > stdout, and stderr, and exits with a zero exit status. Otherwise, the error 10 > is of type Error. 11 12 ### type Error error 13 14 > Error records the actual combined output of executed command, original error 15 > and executed cmd. 16 17 ```go 18 type Error struct { 19 // RunErr is a original occurred error. 20 RunErr error 21 // Cmd is a original executed command. 22 Cmd *exec.Cmd 23 // Output is a combined output of executing command. 24 Output []byte 25 } 26 ``` 27 28 #### func (err *Error) Error() string 29 30 > Error returns string representation of Error type. 31 32 ### func IsExitError(err error) bool 33 34 > IsExitError check that the specified error is an error about exit status. 35 36 ### func GetExitStatus(err error) int 37 38 > GetExitStatus returns 0 if the specified error is not about of exit status. 39 > Otherwise, will be returned actual exit status. 40 41 42 -------------------------------------------------------------------------- 43 44 #### coverage: 100.0% of statements 45 46 ``` 47 github.com/kovetskiy/executil/error.go:20: Error 100.0% 48 github.com/kovetskiy/executil/exit_error.go:8: getWaitStatus 100.0% 49 github.com/kovetskiy/executil/exit_error.go:27: IsExitError 100.0% 50 github.com/kovetskiy/executil/exit_error.go:33: GetExitStatus 100.0% 51 github.com/kovetskiy/executil/run.go:15: Write 100.0% 52 github.com/kovetskiy/executil/run.go:29: Run 100.0% 53 total: (statements) 100.0% 54 ```` 55 | Subject | Behavior | 56 | ------------- | --------------------------------- | 57 | Run | Returns Stdout If Stderr Is Empty | 58 | Run | Returns Stderr If Stdout Is Empty | 59 | Run | Returns Stdout And Stderr If Both Not Empty | 60 | Run | Returns Error If Command Failed | 61 | Run | Returns Error Type Of Executil Error | 62 | Run | Returns Error With Exit Status1 | 63 | Run | Returns Error With Exit Status2 | 64 | Error.Output | Is Combined Output Of Executed Command | 65 | Error.Cmd | Is Actual Executed Command | 66 | Error.RunErr | Is Actual Error Of Executed Command | 67 | Error->Error | Contains Of Actual Error | 68 | Error->Error | Contains Of Command Args | 69 | Error->Error | Contains Of Output If Output Is Not Empty | 70 | Error->Error | Contains Of Message With Output If Output Is Not Empty | 71 | Error->Error | Contains Of Message Without Output If Output Is Empty | 72 | IsExitError | Returns True For Os Exit Error | 73 | IsExitError | Returns True For Executil Error When Run Err Is Exit Error | 74 | IsExitError | Returns False For Executil Error With Non Exec Error | 75 | IsExitError | Returns False For Executil Error With Nil | 76 | IsExitError | Returns False For All Errors | 77 | IsExitError | Returns False For Nil | 78 | GetExitStatus | Returns Exit Status Of Actual Error | 79 | GetExitStatus | Returns Exit Status Of Executil Error With Actual Error | 80 | GetExitStatus | Returns Zero For Nil | 81 | GetExitStatus | Returns Zero For Executil Error With Nil | 82 | GetExitStatus | Returns Zero For Executil Error With Non Exit Error | 83 | GetExitStatus | Returns Zero For Non Exit Error |