Commit b96e074d36
Verified · cmc
internal/control/mirrorcmd.go +3 −1
| @@ -101,6 +101,7 @@ func runMirrorList(c *Ctx, args []string) int { | ||
| 101 | 101 | ds = append(ds, out{m.ID, m.Direction, m.URL, m.Username, m.Dirty, m.LastSync, m.LastError}) |
| 102 | 102 | } |
| 103 | 103 | return c.emit(ds, func(w io.Writer) { |
| 104 | tb := c.table(w, "ID", "DIRECTION", "URL", "LAST", "STATUS") | |
| 104 | 105 | for _, d := range ds { |
| 105 | 106 | status := "ok" |
| 106 | 107 | if d.Pending { |
| @@ -109,8 +110,9 @@ func runMirrorList(c *Ctx, args []string) int { | ||
| 109 | 110 | if d.LastError != "" { |
| 110 | 111 | status = "error: " + d.LastError |
| 111 | 112 | } |
| 112 | fmt.Fprintf(w, "%d\t%s\t%s\tlast %s\t%s\n", d.ID, d.Direction, d.URL, orDash(d.LastSync), status) | |
| 113 | tb.row(cRef(fmt.Sprintf("%d", d.ID)), cText(d.Direction), cText(d.URL), cText("last "+orDash(d.LastSync)), cState(status)) | |
| 113 | 114 | } |
| 115 | tb.flush() | |
| 114 | 116 | }) |
| 115 | 117 | } |
| 116 | 118 | |
internal/control/pagescmd.go +3 −1
| @@ -213,8 +213,10 @@ func runDomainList(c *Ctx, args []string) int { | ||
| 213 | 213 | list = append(list, out{d.Domain, state, d.VerifiedAt}) |
| 214 | 214 | } |
| 215 | 215 | return c.emit(list, func(w io.Writer) { |
| 216 | tb := c.table(w, "DOMAIN", "STATE") | |
| 216 | 217 | for _, d := range list { |
| 217 | fmt.Fprintf(w, "%s\t%s\n", d.Domain, d.State) | |
| 218 | tb.row(cRef(d.Domain), cState(d.State)) | |
| 218 | 219 | } |
| 220 | tb.flush() | |
| 219 | 221 | }) |
| 220 | 222 | } |
internal/control/read.go +7 −3
| @@ -79,12 +79,14 @@ func runRepoRefs(c *Ctx, args []string) int { | ||
| 79 | 79 | d.Tags = append(d.Tags, refOut{Name: ref.Name, SHA: ref.SHA}) |
| 80 | 80 | } |
| 81 | 81 | return c.emit(d, func(w io.Writer) { |
| 82 | tb := c.table(w, "KIND", "NAME", "SHA") | |
| 82 | 83 | for _, ref := range d.Branches { |
| 83 | fmt.Fprintf(w, "branch\t%s\t%.10s\n", ref.Name, ref.SHA) | |
| 84 | tb.row(cText("branch"), cRef(ref.Name), cRef(fmt.Sprintf("%.10s", ref.SHA))) | |
| 84 | 85 | } |
| 85 | 86 | for _, ref := range d.Tags { |
| 86 | fmt.Fprintf(w, "tag\t%s\t%.10s\n", ref.Name, ref.SHA) | |
| 87 | tb.row(cText("tag"), cRef(ref.Name), cRef(fmt.Sprintf("%.10s", ref.SHA))) | |
| 87 | 88 | } |
| 89 | tb.flush() | |
| 88 | 90 | }) |
| 89 | 91 | } |
| 90 | 92 | |
| @@ -283,13 +285,15 @@ func runRepoTree(c *Ctx, args []string) int { | ||
| 283 | 285 | d.Entries = append(d.Entries, eo) |
| 284 | 286 | } |
| 285 | 287 | return c.emit(d, func(w io.Writer) { |
| 288 | tb := c.table(w, "SHA", "SIZE", "NAME") | |
| 286 | 289 | for _, e := range d.Entries { |
| 287 | 290 | name := e.Name |
| 288 | 291 | if e.Type == "tree" { |
| 289 | 292 | name += "/" |
| 290 | 293 | } |
| 291 | fmt.Fprintf(w, "%s\t%s\t%s\n", e.SHA[:min(10, len(e.SHA))], sizeCol(e), name) | |
| 294 | tb.row(cRef(e.SHA[:min(10, len(e.SHA))]), cText(sizeCol(e)), cFlex(name)) | |
| 292 | 295 | } |
| 296 | tb.flush() | |
| 293 | 297 | }) |
| 294 | 298 | } |
| 295 | 299 | |
internal/control/repo.go +15 −5
| @@ -613,9 +613,11 @@ func runAccessList(c *Ctx, args []string) int { | ||
| 613 | 613 | ds = append(ds, out{e.Username, e.Role, e.Source}) |
| 614 | 614 | } |
| 615 | 615 | return c.emit(ds, func(w io.Writer) { |
| 616 | tb := c.table(w, "USER", "ROLE", "SOURCE") | |
| 616 | 617 | for _, d := range ds { |
| 617 | fmt.Fprintf(w, "%s\t%s\tvia %s\n", d.User, d.Role, d.Source) | |
| 618 | tb.row(cRef(d.User), cState(d.Role), cText("via "+d.Source)) | |
| 618 | 619 | } |
| 620 | tb.flush() | |
| 619 | 621 | }) |
| 620 | 622 | } |
| 621 | 623 | |
| @@ -801,9 +803,11 @@ func runTopicsList(c *Ctx, args []string) int { | ||
| 801 | 803 | return c.fail(protocol.ExitFailure, "%v", err) |
| 802 | 804 | } |
| 803 | 805 | return c.emit(topics, func(w io.Writer) { |
| 806 | tb := c.table(w, "TOPIC") | |
| 804 | 807 | for _, t := range topics { |
| 805 | fmt.Fprintln(w, t) | |
| 808 | tb.row(cRef(t)) | |
| 806 | 809 | } |
| 810 | tb.flush() | |
| 807 | 811 | }) |
| 808 | 812 | } |
| 809 | 813 | |
| @@ -858,9 +862,11 @@ func editTopics(c *Ctx, args []string, add bool) int { | ||
| 858 | 862 | return c.fail(protocol.ExitFailure, "%v", err) |
| 859 | 863 | } |
| 860 | 864 | return c.emit(now, func(w io.Writer) { |
| 865 | tb := c.table(w, "TOPIC") | |
| 861 | 866 | for _, t := range now { |
| 862 | fmt.Fprintln(w, t) | |
| 867 | tb.row(cRef(t)) | |
| 863 | 868 | } |
| 869 | tb.flush() | |
| 864 | 870 | }) |
| 865 | 871 | } |
| 866 | 872 | |
| @@ -904,9 +910,11 @@ func runRepoSearch(c *Ctx, args []string) int { | ||
| 904 | 910 | ds = append(ds, out{r.Path(), r.Visibility, desc, topics}) |
| 905 | 911 | } |
| 906 | 912 | return c.emit(ds, func(w io.Writer) { |
| 913 | tb := c.table(w, "PATH", "VISIBILITY", "DESCRIPTION") | |
| 907 | 914 | for _, d := range ds { |
| 908 | fmt.Fprintf(w, "%s\t%s\t%s\n", d.Path, d.Visibility, d.Description) | |
| 915 | tb.row(cRef(d.Path), cState(d.Visibility), cFlex(d.Description)) | |
| 909 | 916 | } |
| 917 | tb.flush() | |
| 910 | 918 | }) |
| 911 | 919 | } |
| 912 | 920 | |
| @@ -1072,9 +1080,11 @@ func runRepoBookmarks(c *Ctx, args []string) int { | ||
| 1072 | 1080 | }) |
| 1073 | 1081 | } |
| 1074 | 1082 | return c.emit(out, func(w io.Writer) { |
| 1083 | tb := c.table(w, "PATH", "COUNT", "DESCRIPTION") | |
| 1075 | 1084 | for _, b := range out { |
| 1076 | fmt.Fprintf(w, "%s\t%d\t%s\n", b.Path, b.Bookmarks, b.Description) | |
| 1085 | tb.row(cRef(b.Path), cNum(int64(b.Bookmarks)), cFlex(b.Description)) | |
| 1077 | 1086 | } |
| 1087 | tb.flush() | |
| 1078 | 1088 | }) |
| 1079 | 1089 | } |
| 1080 | 1090 | |
internal/control/runnerrepo.go +3 −1
| @@ -109,6 +109,7 @@ func runRepoRunnerList(c *Ctx, args []string) int { | ||
| 109 | 109 | runners = []store.RepoRunner{} |
| 110 | 110 | } |
| 111 | 111 | return c.emit(runners, func(w io.Writer) { |
| 112 | tb := c.table(w, "FINGERPRINT", "ALGO", "USER", "SEEN", "HELD") | |
| 112 | 113 | for _, r := range runners { |
| 113 | 114 | seen := r.LastSeen |
| 114 | 115 | if seen == "" { |
| @@ -118,8 +119,9 @@ func runRepoRunnerList(c *Ctx, args []string) int { | ||
| 118 | 119 | if r.BuildNumber != 0 { |
| 119 | 120 | held = fmt.Sprintf("%s #%d %s since %s", r.BuildRepo, r.BuildNumber, r.BuildJob, r.StartedAt) |
| 120 | 121 | } |
| 121 | fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", r.Fingerprint, r.Algo, r.Username, seen, held) | |
| 122 | tb.row(cRef(r.Fingerprint), cText(r.Algo), cText(r.Username), cAge(seen), cText(held)) | |
| 122 | 123 | } |
| 124 | tb.flush() | |
| 123 | 125 | }) |
| 124 | 126 | } |
| 125 | 127 | |
internal/control/sig.go +7 −2
| @@ -80,9 +80,11 @@ func runPGPList(c *Ctx, args []string) int { | ||
| 80 | 80 | ds = append(ds, out{k.Fingerprint, k.UIDsJSON, k.ExpiresAt, k.RevokedAt}) |
| 81 | 81 | } |
| 82 | 82 | return c.emit(ds, func(w io.Writer) { |
| 83 | tb := c.table(w, "FINGERPRINT", "EMAILS") | |
| 83 | 84 | for _, d := range ds { |
| 84 | fmt.Fprintf(w, "%s\t%s\n", d.Fingerprint, d.Emails) | |
| 85 | tb.row(cRef(d.Fingerprint), cText(d.Emails)) | |
| 85 | 86 | } |
| 87 | tb.flush() | |
| 86 | 88 | }) |
| 87 | 89 | } |
| 88 | 90 | |
| @@ -211,9 +213,12 @@ func runRepoLog(c *Ctx, args []string) int { | ||
| 211 | 213 | ds = append(ds, d) |
| 212 | 214 | } |
| 213 | 215 | return c.emit(ds, func(w io.Writer) { |
| 216 | tb := c.table(w, "SHA", "STATE", "SUBJECT", "AUTHOR") | |
| 214 | 217 | for _, d := range ds { |
| 215 | fmt.Fprintf(w, "%.10s %-22s %s (%s <%s>)\n", d.SHA, d.Signature.State, d.Subject, d.AuthorName, d.AuthorEmail) | |
| 218 | tb.row(cRef(fmt.Sprintf("%.10s", d.SHA)), cState(d.Signature.State), cFlex(d.Subject), | |
| 219 | cText(fmt.Sprintf("(%s <%s>)", d.AuthorName, d.AuthorEmail))) | |
| 216 | 220 | } |
| 221 | tb.flush() | |
| 217 | 222 | }) |
| 218 | 223 | } |
| 219 | 224 | |
internal/control/status.go +4 −2
| @@ -118,10 +118,12 @@ func runStatusList(c *Ctx, args []string) int { | ||
| 118 | 118 | Statuses []out `json:"statuses"` |
| 119 | 119 | }{full, combinedOf(statuses), ds} |
| 120 | 120 | return c.emit(d, func(w io.Writer) { |
| 121 | fmt.Fprintf(w, "combined\t%s\t%.10s\n", orNone(d.Combined), d.SHA) | |
| 121 | tb := c.table(w, "CONTEXT", "STATE", "DESCRIPTION") | |
| 122 | tb.row(cText("combined"), cState(orNone(d.Combined)), cText(fmt.Sprintf("%.10s", d.SHA))) | |
| 122 | 123 | for _, x := range ds { |
| 123 | fmt.Fprintf(w, "%s\t%s\t%s\n", x.Context, x.State, x.Description) | |
| 124 | tb.row(cText(x.Context), cState(x.State), cFlex(x.Description)) | |
| 124 | 125 | } |
| 126 | tb.flush() | |
| 125 | 127 | }) |
| 126 | 128 | } |
| 127 | 129 | |
internal/control/webhook.go +9 −4
| @@ -90,9 +90,11 @@ func runWebhookList(c *Ctx, args []string) int { | ||
| 90 | 90 | ds = append(ds, out{h.ID, h.URL, h.Events, h.Active, h.Secret != ""}) |
| 91 | 91 | } |
| 92 | 92 | return c.emit(ds, func(w io.Writer) { |
| 93 | tb := c.table(w, "ID", "URL", "EVENTS") | |
| 93 | 94 | for _, d := range ds { |
| 94 | fmt.Fprintf(w, "%d\t%s\t%s\n", d.ID, d.URL, d.Events) | |
| 95 | tb.row(cRef(fmt.Sprintf("%d", d.ID)), cText(d.URL), cText(d.Events)) | |
| 95 | 96 | } |
| 97 | tb.flush() | |
| 96 | 98 | }) |
| 97 | 99 | } |
| 98 | 100 | |
| @@ -157,13 +159,16 @@ func runWebhookDeliveries(c *Ctx, args []string) int { | ||
| 157 | 159 | rows = append(rows, out{d.ID, d.URL, d.EventKind, d.Status, d.Attempts, d.LastStatus, d.LastError}) |
| 158 | 160 | } |
| 159 | 161 | return c.emit(rows, func(w io.Writer) { |
| 162 | tb := c.table(w, "ID", "EVENT", "URL", "STATUS") | |
| 160 | 163 | for _, d := range rows { |
| 161 | extra := "" | |
| 164 | cells := []cell{cRef(fmt.Sprintf("%d", d.ID)), cText(d.Event), cText(d.URL), | |
| 165 | cState(fmt.Sprintf("%s (%d attempts)", d.Status, d.Attempts))} | |
| 162 | 166 | if d.LastError != "" { |
| 163 | extra = "\t" + d.LastError | |
| 167 | cells = append(cells, cText(d.LastError)) | |
| 164 | 168 | } |
| 165 | fmt.Fprintf(w, "%d\t%s\t%s\t%s (%d attempts)%s\n", d.ID, d.Event, d.URL, d.Status, d.Attempts, extra) | |
| 169 | tb.row(cells...) | |
| 166 | 170 | } |
| 171 | tb.flush() | |
| 167 | 172 | }) |
| 168 | 173 | } |
| 169 | 174 | |
internal/control/wiki.go +3 −1
| @@ -96,9 +96,11 @@ func runWikiList(c *Ctx, args []string) int { | ||
| 96 | 96 | d.Pages = []string{} |
| 97 | 97 | } |
| 98 | 98 | return c.emit(d, func(w io.Writer) { |
| 99 | tb := c.table(w, "PAGE") | |
| 99 | 100 | for _, p := range d.Pages { |
| 100 | fmt.Fprintln(w, p) | |
| 101 | tb.row(cRef(p)) | |
| 101 | 102 | } |
| 103 | tb.flush() | |
| 102 | 104 | }) |
| 103 | 105 | } |
| 104 | 106 | |