(io *iostreams.IOStreams, checks []check)
| 92 | } |
| 93 | |
| 94 | func 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 | } |
no test coverage detected