Commit b96e074d36

b96e074d36b27519e3758af188ec8265e2393686

parent: cd2df24eb6

Verified · cmc

cmc <hello@cleberg.net> · 2026-09-24 01:39 UTC

control: repository, history, status, wiki, mirror, runner and webhook lists as tables

Ref #254
internal/control/mirrorcmd.go +3 −1
@@ -101,6 +101,7 @@ func runMirrorList(c *Ctx, args []string) int {
101101 ds = append(ds, out{m.ID, m.Direction, m.URL, m.Username, m.Dirty, m.LastSync, m.LastError})
102102 }
103103 return c.emit(ds, func(w io.Writer) {
104 tb := c.table(w, "ID", "DIRECTION", "URL", "LAST", "STATUS")
104105 for _, d := range ds {
105106 status := "ok"
106107 if d.Pending {
@@ -109,8 +110,9 @@ func runMirrorList(c *Ctx, args []string) int {
109110 if d.LastError != "" {
110111 status = "error: " + d.LastError
111112 }
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))
113114 }
115 tb.flush()
114116 })
115117}
116118
internal/control/pagescmd.go +3 −1
@@ -213,8 +213,10 @@ func runDomainList(c *Ctx, args []string) int {
213213 list = append(list, out{d.Domain, state, d.VerifiedAt})
214214 }
215215 return c.emit(list, func(w io.Writer) {
216 tb := c.table(w, "DOMAIN", "STATE")
216217 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))
218219 }
220 tb.flush()
219221 })
220222}
internal/control/read.go +7 −3
@@ -79,12 +79,14 @@ func runRepoRefs(c *Ctx, args []string) int {
7979 d.Tags = append(d.Tags, refOut{Name: ref.Name, SHA: ref.SHA})
8080 }
8181 return c.emit(d, func(w io.Writer) {
82 tb := c.table(w, "KIND", "NAME", "SHA")
8283 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)))
8485 }
8586 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)))
8788 }
89 tb.flush()
8890 })
8991}
9092
@@ -283,13 +285,15 @@ func runRepoTree(c *Ctx, args []string) int {
283285 d.Entries = append(d.Entries, eo)
284286 }
285287 return c.emit(d, func(w io.Writer) {
288 tb := c.table(w, "SHA", "SIZE", "NAME")
286289 for _, e := range d.Entries {
287290 name := e.Name
288291 if e.Type == "tree" {
289292 name += "/"
290293 }
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))
292295 }
296 tb.flush()
293297 })
294298}
295299
internal/control/repo.go +15 −5
@@ -613,9 +613,11 @@ func runAccessList(c *Ctx, args []string) int {
613613 ds = append(ds, out{e.Username, e.Role, e.Source})
614614 }
615615 return c.emit(ds, func(w io.Writer) {
616 tb := c.table(w, "USER", "ROLE", "SOURCE")
616617 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))
618619 }
620 tb.flush()
619621 })
620622}
621623
@@ -801,9 +803,11 @@ func runTopicsList(c *Ctx, args []string) int {
801803 return c.fail(protocol.ExitFailure, "%v", err)
802804 }
803805 return c.emit(topics, func(w io.Writer) {
806 tb := c.table(w, "TOPIC")
804807 for _, t := range topics {
805 fmt.Fprintln(w, t)
808 tb.row(cRef(t))
806809 }
810 tb.flush()
807811 })
808812}
809813
@@ -858,9 +862,11 @@ func editTopics(c *Ctx, args []string, add bool) int {
858862 return c.fail(protocol.ExitFailure, "%v", err)
859863 }
860864 return c.emit(now, func(w io.Writer) {
865 tb := c.table(w, "TOPIC")
861866 for _, t := range now {
862 fmt.Fprintln(w, t)
867 tb.row(cRef(t))
863868 }
869 tb.flush()
864870 })
865871}
866872
@@ -904,9 +910,11 @@ func runRepoSearch(c *Ctx, args []string) int {
904910 ds = append(ds, out{r.Path(), r.Visibility, desc, topics})
905911 }
906912 return c.emit(ds, func(w io.Writer) {
913 tb := c.table(w, "PATH", "VISIBILITY", "DESCRIPTION")
907914 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))
909916 }
917 tb.flush()
910918 })
911919}
912920
@@ -1072,9 +1080,11 @@ func runRepoBookmarks(c *Ctx, args []string) int {
10721080 })
10731081 }
10741082 return c.emit(out, func(w io.Writer) {
1083 tb := c.table(w, "PATH", "COUNT", "DESCRIPTION")
10751084 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))
10771086 }
1087 tb.flush()
10781088 })
10791089}
10801090
internal/control/runnerrepo.go +3 −1
@@ -109,6 +109,7 @@ func runRepoRunnerList(c *Ctx, args []string) int {
109109 runners = []store.RepoRunner{}
110110 }
111111 return c.emit(runners, func(w io.Writer) {
112 tb := c.table(w, "FINGERPRINT", "ALGO", "USER", "SEEN", "HELD")
112113 for _, r := range runners {
113114 seen := r.LastSeen
114115 if seen == "" {
@@ -118,8 +119,9 @@ func runRepoRunnerList(c *Ctx, args []string) int {
118119 if r.BuildNumber != 0 {
119120 held = fmt.Sprintf("%s #%d %s since %s", r.BuildRepo, r.BuildNumber, r.BuildJob, r.StartedAt)
120121 }
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))
122123 }
124 tb.flush()
123125 })
124126}
125127
internal/control/sig.go +7 −2
@@ -80,9 +80,11 @@ func runPGPList(c *Ctx, args []string) int {
8080 ds = append(ds, out{k.Fingerprint, k.UIDsJSON, k.ExpiresAt, k.RevokedAt})
8181 }
8282 return c.emit(ds, func(w io.Writer) {
83 tb := c.table(w, "FINGERPRINT", "EMAILS")
8384 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))
8586 }
87 tb.flush()
8688 })
8789}
8890
@@ -211,9 +213,12 @@ func runRepoLog(c *Ctx, args []string) int {
211213 ds = append(ds, d)
212214 }
213215 return c.emit(ds, func(w io.Writer) {
216 tb := c.table(w, "SHA", "STATE", "SUBJECT", "AUTHOR")
214217 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)))
216220 }
221 tb.flush()
217222 })
218223}
219224
internal/control/status.go +4 −2
@@ -118,10 +118,12 @@ func runStatusList(c *Ctx, args []string) int {
118118 Statuses []out `json:"statuses"`
119119 }{full, combinedOf(statuses), ds}
120120 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)))
122123 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))
124125 }
126 tb.flush()
125127 })
126128}
127129
internal/control/webhook.go +9 −4
@@ -90,9 +90,11 @@ func runWebhookList(c *Ctx, args []string) int {
9090 ds = append(ds, out{h.ID, h.URL, h.Events, h.Active, h.Secret != ""})
9191 }
9292 return c.emit(ds, func(w io.Writer) {
93 tb := c.table(w, "ID", "URL", "EVENTS")
9394 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))
9596 }
97 tb.flush()
9698 })
9799}
98100
@@ -157,13 +159,16 @@ func runWebhookDeliveries(c *Ctx, args []string) int {
157159 rows = append(rows, out{d.ID, d.URL, d.EventKind, d.Status, d.Attempts, d.LastStatus, d.LastError})
158160 }
159161 return c.emit(rows, func(w io.Writer) {
162 tb := c.table(w, "ID", "EVENT", "URL", "STATUS")
160163 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))}
162166 if d.LastError != "" {
163 extra = "\t" + d.LastError
167 cells = append(cells, cText(d.LastError))
164168 }
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...)
166170 }
171 tb.flush()
167172 })
168173}
169174
internal/control/wiki.go +3 −1
@@ -96,9 +96,11 @@ func runWikiList(c *Ctx, args []string) int {
9696 d.Pages = []string{}
9797 }
9898 return c.emit(d, func(w io.Writer) {
99 tb := c.table(w, "PAGE")
99100 for _, p := range d.Pages {
100 fmt.Fprintln(w, p)
101 tb.row(cRef(p))
101102 }
103 tb.flush()
102104 })
103105}
104106