MCPcopy
hub / github.com/cli/cli / printTable

Function printTable

pkg/cmd/pr/checks/output.go:94–132  ·  view source on GitHub ↗
(io *iostreams.IOStreams, checks []check)

Source from the content-addressed store, hash-verified

92}
93
94func printTable(io *iostreams.IOStreams, checks []check) error {
95 var headers []string
96 if io.IsStdoutTTY() {
97 headers = []string{"", "NAME", "DESCRIPTION", "ELAPSED", "URL"}
98 } else {
99 headers = []string{"NAME", "STATUS", "ELAPSED", "URL", "DESCRIPTION"}
100 }
101
102 tp := tableprinter.New(io, tableprinter.WithHeader(headers...))
103
104 sort.Slice(checks, func(i, j int) bool {
105 b0 := checks[i].Bucket
106 n0 := checks[i].Name
107 l0 := checks[i].Link
108 b1 := checks[j].Bucket
109 n1 := checks[j].Name
110 l1 := checks[j].Link
111
112 if b0 == b1 {
113 if n0 == n1 {
114 return l0 < l1
115 }
116 return n0 < n1
117 }
118
119 return (b0 == "fail") || (b0 == "pending" && b1 == "success")
120 })
121
122 for _, o := range checks {
123 addRow(tp, io, o)
124 }
125
126 err := tp.Render()
127 if err != nil {
128 return err
129 }
130
131 return nil
132}

Callers 1

checksRunFunction · 0.70

Calls 5

NewFunction · 0.92
WithHeaderFunction · 0.92
addRowFunction · 0.85
IsStdoutTTYMethod · 0.80
RenderMethod · 0.65

Tested by

no test coverage detected