MCPcopy
hub / github.com/cli/cli / addRow

Function addRow

pkg/cmd/pr/checks/output.go:11–67  ·  view source on GitHub ↗
(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check)

Source from the content-addressed store, hash-verified

9)
10
11func addRow(tp *tableprinter.TablePrinter, io *iostreams.IOStreams, o check) {
12 cs := io.ColorScheme()
13 elapsed := ""
14
15 if !o.StartedAt.IsZero() && !o.CompletedAt.IsZero() {
16 e := o.CompletedAt.Sub(o.StartedAt)
17 if e > 0 {
18 elapsed = e.String()
19 }
20 }
21
22 mark := "✓"
23 markColor := cs.Green
24 switch o.Bucket {
25 case "fail":
26 mark = "X"
27 markColor = cs.Red
28 case "pending":
29 mark = "*"
30 markColor = cs.Yellow
31 case "skipping", "cancel":
32 mark = "-"
33 markColor = cs.Muted
34 }
35
36 if io.IsStdoutTTY() {
37 var name string
38 if o.Workflow != "" {
39 name += fmt.Sprintf("%s/", o.Workflow)
40 }
41 name += o.Name
42 if o.Event != "" {
43 name += fmt.Sprintf(" (%s)", o.Event)
44 }
45 tp.AddField(mark, tableprinter.WithColor(markColor))
46 tp.AddField(name)
47 tp.AddField(o.Description)
48 tp.AddField(elapsed)
49 tp.AddField(o.Link)
50 } else {
51 tp.AddField(o.Name)
52 if o.Bucket == "cancel" {
53 tp.AddField("fail")
54 } else {
55 tp.AddField(o.Bucket)
56 }
57 if elapsed == "" {
58 tp.AddField("0")
59 } else {
60 tp.AddField(elapsed)
61 }
62 tp.AddField(o.Link)
63 tp.AddField(o.Description)
64 }
65
66 tp.EndRow()
67}
68

Callers 1

printTableFunction · 0.85

Calls 3

ColorSchemeMethod · 0.80
IsStdoutTTYMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected