MCPcopy
hub / github.com/vmware-tanzu/sonobuoy / CombinedOutputLines

Function CombinedOutputLines

pkg/image/exec/exec.go:66–76  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
66func 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
79func InheritOutput(cmd Cmd) {

Callers 1

RunMethod · 0.92

Calls 3

SetStdoutMethod · 0.65
SetStderrMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected