CombinedOutputLines is like os/exec's cmd.CombinedOutput(), but over our Cmd interface, and instead of returning the byte buffer of stderr + stdout, it scans these for lines and returns a slice of output lines
(cmd Cmd)
| 64 | // but over our Cmd interface, and instead of returning the byte buffer of |
| 65 | // stderr + stdout, it scans these for lines and returns a slice of output lines |
| 66 | func CombinedOutputLines(cmd Cmd) (lines []string, err error) { |
| 67 | var buff bytes.Buffer |
| 68 | cmd.SetStdout(&buff) |
| 69 | cmd.SetStderr(&buff) |
| 70 | err = cmd.Run() |
| 71 | scanner := bufio.NewScanner(&buff) |
| 72 | for scanner.Scan() { |
| 73 | lines = append(lines, scanner.Text()) |
| 74 | } |
| 75 | return lines, err |
| 76 | } |
| 77 | |
| 78 | // InheritOutput sets cmd's output to write to the current process's stdout and stderr |
| 79 | func InheritOutput(cmd Cmd) { |