-
Notifications
You must be signed in to change notification settings - Fork 4
/
response.go
53 lines (42 loc) · 902 Bytes
/
response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package kh
import (
"fmt"
"strings"
)
type Response struct {
Stdout []string
Stderr []string
Log []string
Verbose bool
}
func (r *Response) SetVerbose(verbose bool) {
r.Verbose = verbose
}
func (r *Response) Debugf(format string, args ...interface{}) {
if r.Verbose {
r.WriteLog(fmt.Sprintf(format, args))
}
}
func (r *Response) Debug(msg string) {
if r.Verbose {
r.WriteLog(msg)
}
}
func (r *Response) SprintLog() string {
return strings.Join(r.Log, "\n")
}
func (r *Response) SprintStdout() string {
return strings.Join(r.Stdout, "\n")
}
func (r *Response) SprintStderr() string {
return strings.Join(r.Stderr, "\n")
}
func (r *Response) WriteLog(entry string) {
r.Log = append(r.Log, entry)
}
func (r *Response) WriteStdout(entry string) {
r.Stdout = append(r.Stdout, entry)
}
func (r *Response) WriteStderr(entry string) {
r.Stderr = append(r.Stderr, entry)
}