diff options
| -rw-r--r-- | human.go | 111 | ||||
| -rw-r--r-- | humanShowRepo.go | 90 | ||||
| -rw-r--r-- | tableConfigs.go | 41 |
3 files changed, 39 insertions, 203 deletions
diff --git a/human.go b/human.go deleted file mode 100644 index fab41d1..0000000 --- a/human.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -// OLD STUFF. REMOVE. USE PROTOBUF TABLES - -// mostly just functions related to making STDOUT -// more readable by us humans - -// also function shortcuts the do fixed limited formatting (it's like COBOL) -// so reporting tables of the status of what droplets and hypervisors -// are in text columns and rows that can be easily read in a terminal - -/* -func standardHeader() string { - return fmt.Sprintf("%-4s %-40s %s", "", "Path", "flags") -} - -func (f *Forge) standardHeader(r *ForgeConfig) string { - var flags string - var readonly string - if f.Config.IsPrivate(r.GoPath) { - flags += "(private) " - } - if f.Config.IsFavorite(r.GoPath) { - flags += "(favorite) " - } - if f.Config.IsReadOnly(r.GoPath) { - readonly = "" - } else { - readonly = "r/w" - } - if r.MasterBranchName != "" { - flags += "(master=" + r.MasterBranchName + ") " - } - if r.DevelBranchName != "" { - flags += "(devel=" + r.DevelBranchName + ") " - } - if r.UserBranchName != "" { - flags += "(user=" + r.UserBranchName + ") " - } - if r.DebName != "" { - flags += "(deb=" + r.DebName + ") " - } - return fmt.Sprintf("%-4s %-40s %s", readonly, r.GoPath, flags) -} - -// print a human readable table to STDOUT -func (f *Forge) ConfigPrintTable() { - if f == nil { - return - } - log.Info(standardHeader()) - all := f.Config.All() - for all.Scan() { - r := all.Next() - log.Info(f.standardHeader(r)) - } -} - -// show information while doing golang releases -func (f *Forge) StandardReleaseHeader(repo *gitpb.Repo, state string) string { - // tag := repo.NewestTag() - // gitAge, _ := tag.GetDate() - dur := repo.NewestAge() - - curname := repo.GetCurrentBranchName() - - lastTag := repo.GetLastTag() - target := repo.GetTargetVersion() - master := repo.GetMasterVersion() - user := repo.GetUserVersion() - - header := fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-20s %-20s %-15s", - repo.GetGoPath(), shell.FormatDuration(dur), curname, - lastTag, target, master, user, - state) - return header -} - -func ReleaseReportHeader() string { - return fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-20s %-20s %-15s", - "REPO", "AGE", "CUR BR", - "LAST", "TARGET", - "MASTER", "USER", - "STATE") -} - -func (f *Forge) PrintReleaseReport(repos *gitpb.Repos) int { - var count int - - log.Info(ReleaseReportHeader()) - - loop := repos.SortByFullPath() - for loop.Scan() { - check := loop.Next() - count += 1 - if check == nil { - // wtf - continue - } - var state string - if check.CheckDirty() { - state = "(dirty)" - } - log.Info(f.StandardReleaseHeader(check, state)) - } - log.Info(fmt.Sprintf("total repo count = %d", count)) - return count -} -*/ diff --git a/humanShowRepo.go b/humanShowRepo.go deleted file mode 100644 index cbc433d..0000000 --- a/humanShowRepo.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -/* -func (f *Forge) HumanPrintRepo(check *gitpb.Repo) { - if check == nil { - log.Info("forge: you sent me nil") - return - } - - if check.GetTargetVersion() == "" { - log.Info("TargetVersion == blank") - } - if check.GetTargetVersion() == check.GetCurrentVersion() { - log.Info("IsReleased() == true. do not release this a second time") - } else { - log.Info("IsReleased() == false") - } - if check.CheckDirty() { - log.Info("CheckDirty() == true. do not release dirty repos") - } else { - log.Info("CheckDirty() == false") - } - if check.GetGoPrimitive() { - log.Info("IsPrimitive() == true") - } else { - log.Info("IsPrimitive() == false") - } - if f.Config.IsPrivate(check.GetGoPath()) { - log.Info("IsPrivate() == true") - } else { - log.Info("IsPrivate() == false") - } - if ok, compiled, err := check.ScanProtobuf(); ok { - log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled)) - if err != nil { - log.Info("IsProtobuf() ERROR = ", err) - } - for _, s := range compiled { - log.Info("\tcompiled file found:", s) - } - } else { - log.Info("IsProtobuf() == false") - if err != nil { - log.Info("IsProtobuf() ERROR = ", err) - } - } - log.Info("git master name ==", check.GetMasterBranchName()) - log.Info("git devel name ==", check.GetDevelBranchName()) - log.Info("git user name ==", check.GetUserBranchName()) - log.Info("git current name ==", check.GetCurrentBranchName()) - - // testNext(check) - // f.PrintHumanTable(check) - - printTime("Last Pull", check.Times.LastPull.AsTime()) - printTime("Last Dirty", check.Times.LastDirty.AsTime()) - printTime("dir mtime", check.Times.MtimeDir.AsTime()) - printTime("HEAD mtime", check.Times.MtimeHead.AsTime()) - printTime("Index mtime", check.Times.MtimeIndex.AsTime()) - printTime("fetch", check.Times.MtimeFetch.AsTime()) - printTime("last go.sum", check.Times.LastGoDep.AsTime()) - printTime("last commit", check.Times.NewestCommit.AsTime()) - - now := time.Now() - dur := now.Sub(check.Times.LastUpdate.AsTime()) - log.Printf("Repo Last Reload: %s\n", shell.FormatDuration(dur)) -} - -func (f *Forge) testGoRepo(check *gitpb.Repo) { - data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod")) - log.Info(string(data)) - - if err := f.FinalGoDepsCheckOk(check, true); err == nil { - log.Info("forge.FinalGoDepsCheck(check) worked!") - } else { - log.Info("forge.FinalGoDepsCheck(check) failed. boo.") - } - -} - -func printTime(s string, t time.Time) { - now := time.Now() - dur := now.Sub(t) - if dur < (time.Hour * 24) { - log.Printf("%s mtime last changed %s\n", s, shell.FormatDuration(dur)) - } -} -*/ diff --git a/tableConfigs.go b/tableConfigs.go index 914c4af..1bbc95b 100644 --- a/tableConfigs.go +++ b/tableConfigs.go @@ -20,7 +20,44 @@ func (pb *ForgeConfigs) MakeTable() *ForgeConfigsTable { t := pb.NewTable("tagList") t.NewUuid() - col := t.AddNamespace() - col.Width = 28 + // col := t.AddDirectory() + // col.Width = 6 + + var col *ForgeConfigFunc + + col = t.AddStringFunc("write", func(c *ForgeConfig) string { + if c.Writable { + return " r/w" + } + return "" + }) + col.Width = 5 + + col = t.AddStringFunc("private", func(c *ForgeConfig) string { + if c.Private { + return "true" + } + return "" + }) + col.Width = 7 + + col = t.AddStringFunc("dir", func(c *ForgeConfig) string { + if c.Directory { + return "true" + } + return "" + }) + col.Width = 5 + + col = t.AddStringFunc("watch", func(c *ForgeConfig) string { + if c.Favorite { + return "true" + } + return "" + }) + col.Width = 5 + + col = t.AddNamespace() + col.Width = -1 return t } |
