repolist/human.go

112 lines
2.3 KiB
Go
Raw Normal View History

package repolist
// make human readable output
import (
"fmt"
"time"
"go.wit.com/lib/gui/shell"
)
// makes a human readable thing for standard out.
2024-11-13 17:05:07 -06:00
// https://pkg.go.dev/fmt has good references for Sprintf
func (r *RepoRow) StandardHeader() string {
lastTag := r.LastTag()
tag := r.Status.NewestTag()
gitAge, _ := tag.GetDate()
dur := time.Since(gitAge)
target := r.Status.GetTargetVersion()
master := r.Status.GetMasterVersion()
devel := r.Status.GetDevelVersion()
user := r.Status.GetUserVersion()
header := fmt.Sprintf("%-35s %5s %-10s %-10s %-20s %-20s %-20s %-15s",
2024-11-08 06:43:45 -06:00
r.Name(), shell.FormatDuration(dur),
lastTag, target,
2024-11-08 06:43:45 -06:00
master, devel, user,
r.State())
return header
}
func ReportHeader() string {
return fmt.Sprintf("%-35s %5s %-10s %-10s %-20s %-20s %-20s %-15s",
"REPO", "AGE",
"LAST", "TARGET",
"MASTER", "DEVEL", "USER",
"STATE")
}
2024-12-02 07:00:51 -06:00
/*
2024-11-07 05:07:36 -06:00
func (v *RepoList) PrintReport(readonly string, onlydirty string, perfect string) {
var count int
2024-11-07 03:41:26 -06:00
log.Info(ReportHeader())
loop := v.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
count += 1
header := repo.StandardHeader()
if onlydirty == "true" {
if repo.CheckDirty() {
2024-11-08 06:43:45 -06:00
log.Info(header + "")
}
continue
}
if repo.ReadOnly() {
if readonly == "true" {
2024-11-08 06:43:45 -06:00
log.Info(header + "readonly")
}
continue
}
if repo.State() == "PERFECT" {
if perfect == "false" {
continue
}
}
if repo.State() != "merge to main" {
2024-11-08 06:43:45 -06:00
log.Info(header + "")
continue
}
if repo.CheckDirty() {
2024-11-08 06:43:45 -06:00
log.Info(header + "")
continue
}
2024-11-08 06:43:45 -06:00
log.Info(header + "")
}
2024-11-07 03:41:26 -06:00
log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count))
}
2024-12-02 07:00:51 -06:00
*/
// makes a human readable thing for standard out.
func (r *RepoRow) StandardReleaseHeader() string {
lastTag := r.LastTag()
tag := r.Status.NewestTag()
gitAge, _ := tag.GetDate()
dur := time.Since(gitAge)
curname := r.Status.GetCurrentBranchName()
master := r.Status.GetMasterVersion()
user := r.Status.GetUserVersion()
target := r.Status.GetTargetVersion()
header := fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-20s %-20s %-15s",
r.Name(), shell.FormatDuration(dur), curname,
lastTag, target,
master, user,
r.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")
}