summaryrefslogtreecommitdiff
path: root/tableDefault.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-04 03:45:49 -0500
committerJeff Carr <[email protected]>2025-10-04 03:45:49 -0500
commit8d535b0a0771ceb53a4163226b1d7d5f95052989 (patch)
treefdbef32a60674ea185024c8aba37fac836cce528 /tableDefault.go
parent5ee8c4f295205e7bfd316b43a503f1ec281a1b03 (diff)
start removing old table codev0.0.163
Diffstat (limited to 'tableDefault.go')
-rw-r--r--tableDefault.go104
1 files changed, 104 insertions, 0 deletions
diff --git a/tableDefault.go b/tableDefault.go
new file mode 100644
index 0000000..2cb8f9a
--- /dev/null
+++ b/tableDefault.go
@@ -0,0 +1,104 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package forgepb
+
+import (
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/gitpb"
+)
+
+// this is the default table layout for repos in forge
+
+func (f *Forge) PrintDefaultTB(pb *gitpb.Repos) {
+ tablePB := f.makeDefaultTB(pb)
+ tablePB.PrintTable()
+}
+
+func (f *Forge) getRepoType(repo *gitpb.Repo) string {
+ var rtype string = repo.GetRepoType()
+ switch rtype {
+ case "binary":
+ rtype = "GO bin"
+ case "library":
+ rtype = "GO lib"
+ case "protobuf":
+ rtype = "GO pb"
+ }
+ if f.IsPrivate(repo) {
+ rtype = "priv"
+ }
+ return rtype
+}
+
+func (f *Forge) makeDefaultTB(pb *gitpb.Repos) *gitpb.ReposTable {
+ t := pb.NewTable("forgedList")
+ t.NewUuid()
+
+ var col *gitpb.RepoFunc
+
+ col = t.AddNamespace()
+ col.Width = 33
+
+ col = t.AddCurrentBranchName()
+ col.Width = 7
+ col.Header.Name = "current"
+
+ col = t.AddStringFunc("age", func(r *gitpb.Repo) string {
+ if r.IsDirty() {
+ return ""
+ }
+ dur := r.NewestAge()
+ return shell.FormatDuration(dur)
+ })
+ col.Width = 3
+
+ col = t.AddStringFunc("user", func(r *gitpb.Repo) string {
+ ver := r.GetUserVersion()
+ if r.IsDirty() {
+ ver = "* " + ver
+ }
+ return ver
+ })
+ col.Width = 14
+
+ col = t.AddDevelVersion()
+ col.Width = 12
+ col.Header.Name = "devel"
+
+ col = t.AddMasterVersion()
+ col.Width = 12
+ col.Header.Name = "master"
+
+ col = t.AddStringFunc("type", func(r *gitpb.Repo) string {
+ return f.getRepoType(r)
+ })
+ col.Width = 6
+
+ col = t.AddStringFunc("r/w", func(r *gitpb.Repo) string {
+ if f.IsWritable(r) {
+ return "rw"
+ }
+ return ""
+ })
+ col.Width = 3
+
+ col = t.AddURL()
+ col.Width = 42
+
+ col = t.AddState()
+ col.Width = -1
+ return t
+}
+
+// // the old function names
+func (f *Forge) PrintHumanTable(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}
+
+func (f *Forge) PrintHumanTableFull(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}
+
+func (f *Forge) PrintHumanTableDirty(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}