Repository navigation
Expand file tree
/
Copy pathcmdout.go
More file actions
69 lines (62 loc) · 3.21 KB
/
Copy pathcmdout.go
File metadata and controls
69 lines (62 loc) · 3.21 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package runn
import (
"fmt"
"io"
"net/http"
"github.com/fatih/color"
)
var _ Capturer = (*cmdOut)(nil)
type cmdOut struct {
out io.Writer
errs error
green func(a ...interface{}) string
yellow func(a ...interface{}) string
red func(a ...interface{}) string
}
func NewCmdOut(out io.Writer) *cmdOut {
return &cmdOut{
out: out,
green: color.New(color.FgGreen).SprintFunc(),
yellow: color.New(color.FgYellow).SprintFunc(),
red: color.New(color.FgRed).SprintFunc(),
}
}
func (d *cmdOut) CaptureStart(ids IDs, bookPath, desc string) {}
func (d *cmdOut) CaptureFailure(ids IDs, bookPath, desc string, err error) {
_, _ = fmt.Fprintf(d.out, "%s ... %v\n", desc, d.red(err))
}
func (d *cmdOut) CaptureSkipped(ids IDs, bookPath, desc string) {
_, _ = fmt.Fprintf(d.out, "%s ... %s\n", desc, d.yellow("skip"))
}
func (d *cmdOut) CaptureSuccess(ids IDs, bookPath, desc string) {
_, _ = fmt.Fprintf(d.out, "%s ... %s\n", desc, d.green("ok"))
}
func (d *cmdOut) CaptureEnd(ids IDs, bookPath, desc string) {}
func (d *cmdOut) CaptureHTTPRequest(name string, req *http.Request) {}
func (d *cmdOut) CaptureHTTPResponse(name string, res *http.Response) {}
func (d *cmdOut) CaptureGRPCStart(name string, typ GRPCType, service, method string) {}
func (d *cmdOut) CaptureGRPCRequestHeaders(h map[string][]string) {}
func (d *cmdOut) CaptureGRPCRequestMessage(m map[string]interface{}) {}
func (d *cmdOut) CaptureGRPCResponseStatus(status int) {}
func (d *cmdOut) CaptureGRPCResponseHeaders(h map[string][]string) {}
func (d *cmdOut) CaptureGRPCResponseMessage(m map[string]interface{}) {}
func (d *cmdOut) CaptureGRPCResponseTrailers(t map[string][]string) {}
func (d *cmdOut) CaptureGRPCClientClose() {}
func (d *cmdOut) CaptureGRPCEnd(name string, typ GRPCType, service, method string) {}
func (d *cmdOut) CaptureCDPStart(name string) {}
func (d *cmdOut) CaptureCDPAction(a CDPAction) {}
func (d *cmdOut) CaptureCDPResponse(a CDPAction, res map[string]interface{}) {}
func (d *cmdOut) CaptureCDPEnd(name string) {}
func (d *cmdOut) CaptureSSHCommand(command string) {}
func (d *cmdOut) CaptureSSHStdout(stdout string) {}
func (d *cmdOut) CaptureSSHStderr(stderr string) {}
func (d *cmdOut) CaptureDBStatement(name string, stmt string) {}
func (d *cmdOut) CaptureDBResponse(name string, res *DBResponse) {}
func (d *cmdOut) CaptureExecCommand(command string) {}
func (d *cmdOut) CaptureExecStdin(stdin string) {}
func (d *cmdOut) CaptureExecStdout(stdout string) {}
func (d *cmdOut) CaptureExecStderr(stderr string) {}
func (d *cmdOut) SetCurrentIDs(ids IDs) {}
func (d *cmdOut) Errs() error {
return d.errs
}