works at 80x24. I'm rather proud of this app.
This commit is contained in:
parent
964aaf823d
commit
e3c8669be4
122
humanTable.go
122
humanTable.go
|
@ -11,29 +11,8 @@ import (
|
|||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// you can replace all of COBOL with this amount of GO
|
||||
|
||||
// ah yes, COBOL. what an ancient throwback. for those that know
|
||||
// then you know exactly what is in this file. For those that don't, here it is:
|
||||
|
||||
// All this does is output human readable text formatted to be viewable on
|
||||
// a console with a fixed with font. AKA: a typerwriter. Which is exactly
|
||||
// what COBOL did in the 1970's (60s? notsure) And the 80s.
|
||||
|
||||
// So, you want to dump out stuff on the console. Let's see. Something like
|
||||
|
||||
/*
|
||||
forge --favorites
|
||||
|
||||
go.wit.com/apps/myapp v0.2.0 (installed)
|
||||
go.wit.com/lib/somethingfun v0.0.7 (not downloaded)
|
||||
*/
|
||||
|
||||
// anyway, you get the idea. This is also called COBOL because it does on
|
||||
// thing and truncates every line output to the columns you see with stty -a
|
||||
// my monitor is huge, so it's not going to work at 80x24. 160x48 is better
|
||||
// actually, I'd predict some of these will probably end up 240 wide
|
||||
// long live good eyesight and 4K monitors!
|
||||
// a console with a fixed with font. AKA: a typerwriter
|
||||
|
||||
func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
|
||||
log.DaemonMode(true)
|
||||
|
@ -41,8 +20,8 @@ func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
|
|||
t := new(tally)
|
||||
|
||||
// print the header
|
||||
args := []string{"namespace", "cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type"}
|
||||
sizes := []int{40, 9, 6, 16, 16, 16, 1, 12, 12, 8}
|
||||
args := []string{"namespace", "branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type"}
|
||||
sizes := []int{35, 9, 4, 13, 13, 13, 1, 12, 12, 8}
|
||||
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
|
||||
|
||||
all := allr.SortByFullPath()
|
||||
|
@ -60,8 +39,8 @@ func (f *Forge) PrintForgedTable(allr *gitpb.Repos) {
|
|||
t := new(tally)
|
||||
|
||||
// print the header
|
||||
args := []string{"namespace", "cur br", "age", "master", "devel", "last tag", "", "", "", ""}
|
||||
sizes := []int{40, 9, 6, 12, 16, 16, 16, 12, 12, 8}
|
||||
args := []string{"namespace", "branch", "age", "master", "devel", "last tag", "", "", "", ""}
|
||||
sizes := []int{35, 9, 4, 13, 13, 13, 13, 12, 12, 8}
|
||||
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
|
||||
|
||||
all := allr.SortByFullPath()
|
||||
|
@ -70,7 +49,7 @@ func (f *Forge) PrintForgedTable(allr *gitpb.Repos) {
|
|||
f.printForgedToTable(repo, sizes)
|
||||
tallyBranchTotals(t, repo)
|
||||
}
|
||||
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
|
||||
log.Infof("Total repositories: %d (%d user) (%d devel) (%d master) (%d unknown)\n", t.total, t.user, t.devel, t.master, t.unknown)
|
||||
}
|
||||
|
||||
func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) {
|
||||
|
@ -79,8 +58,8 @@ func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) {
|
|||
t := new(tally)
|
||||
|
||||
// print the header
|
||||
args := []string{"cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type", "namespace"}
|
||||
sizes := []int{9, 6, 16, 16, 16, 1, 12, 12, 8, 0}
|
||||
args := []string{"branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type", "namespace"}
|
||||
sizes := []int{9, 4, 13, 13, 13, 1, 12, 12, 8, 0}
|
||||
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
|
||||
|
||||
all := allr.SortByFullPath()
|
||||
|
@ -89,7 +68,7 @@ func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) {
|
|||
f.printRepoToTable(repo, sizes, true)
|
||||
tallyBranchTotals(t, repo)
|
||||
}
|
||||
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
|
||||
log.Infof("Total repositories: %d (%d user) (%d devel) (%d master) (%d unknown)\n", t.total, t.user, t.devel, t.master, t.unknown)
|
||||
}
|
||||
|
||||
// also shows which files are dirty
|
||||
|
@ -99,8 +78,8 @@ func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) {
|
|||
t := new(tally)
|
||||
|
||||
// print the header
|
||||
args := []string{"namespace", "cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type"}
|
||||
sizes := []int{40, 9, 6, 16, 16, 16, 1, 12, 12, 8}
|
||||
args := []string{"namespace", "branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type"}
|
||||
sizes := []int{35, 9, 4, 13, 13, 13, 1, 12, 12, 8}
|
||||
log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args)))
|
||||
|
||||
for repo := range allr.IterAll() {
|
||||
|
@ -115,7 +94,7 @@ func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) {
|
|||
|
||||
tallyBranchTotals(t, repo)
|
||||
}
|
||||
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
|
||||
log.Infof("Total repositories: %d (%d user) (%d devel) (%d master) (%d unknown)\n", t.total, t.user, t.devel, t.master, t.unknown)
|
||||
}
|
||||
|
||||
// used to count which repos are on which branches (master/main, devel, user)
|
||||
|
@ -142,82 +121,20 @@ func tallyBranchTotals(t *tally, repo *gitpb.Repo) {
|
|||
t.user += 1
|
||||
return
|
||||
}
|
||||
log.Printf("unknown curr=%s master=%s devel=%s user=%s\n", repo.GetCurrentBranchName(), repo.GetMasterBranchName(), repo.GetDevelBranchName(), repo.GetUserBranchName())
|
||||
log.Printf("unknown curr=%s user=%s devel=%s master=%s\n", repo.GetCurrentBranchName(), repo.GetUserBranchName(), repo.GetDevelBranchName(), repo.GetMasterBranchName())
|
||||
t.unknown += 1
|
||||
}
|
||||
|
||||
/*
|
||||
func standardTable5(arg1, arg2, arg3, arg4, arg5 string) string {
|
||||
len1 := 40
|
||||
len2 := 12
|
||||
len3 := 12
|
||||
len4 := 16
|
||||
len5 := 8
|
||||
var s string
|
||||
if len(arg1) > len1 {
|
||||
arg1 = arg1[:len1]
|
||||
}
|
||||
s = "%-" + fmt.Sprintf("%d", len1) + "s "
|
||||
if len(arg2) > len2 {
|
||||
arg2 = arg2[:len2]
|
||||
}
|
||||
s += "%-" + fmt.Sprintf("%d", len2) + "s "
|
||||
if len(arg3) > len3 {
|
||||
arg3 = arg3[:len3]
|
||||
}
|
||||
s += "%-" + fmt.Sprintf("%d", len3) + "s "
|
||||
if len(arg4) > len4 {
|
||||
arg4 = arg4[:len4]
|
||||
}
|
||||
s += "%-" + fmt.Sprintf("%d", len4) + "s "
|
||||
if len(arg5) > len5 {
|
||||
arg5 = arg5[:len5]
|
||||
}
|
||||
s += "%-" + fmt.Sprintf("%d", len5) + "s"
|
||||
return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
func standardTableSize10(sizes []int, args []string) string {
|
||||
var s string
|
||||
for i, si := range sizes {
|
||||
if si == 0 {
|
||||
s += "%-s "
|
||||
} else {
|
||||
s += "%-" + fmt.Sprintf("%d", si) + "s "
|
||||
if len(args[i]) > sizes[i] {
|
||||
args[i] = args[i][:sizes[i]]
|
||||
}
|
||||
}
|
||||
}
|
||||
// there must be a better syntax for this
|
||||
arg1 := args[0]
|
||||
arg2 := args[1]
|
||||
arg3 := args[2]
|
||||
arg4 := args[3]
|
||||
arg5 := args[4]
|
||||
arg6 := args[5]
|
||||
arg7 := args[6]
|
||||
arg8 := args[7]
|
||||
arg9 := args[8]
|
||||
arg10 := args[9]
|
||||
|
||||
return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
|
||||
// return fmt.Sprintf(s, args)
|
||||
}
|
||||
*/
|
||||
|
||||
func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) {
|
||||
var end string
|
||||
|
||||
// shortened version numbers
|
||||
var mhort string = repo.GetMasterVersion()
|
||||
var dhort string = repo.GetDevelVersion()
|
||||
var uhort string = repo.GetUserVersion()
|
||||
if uhort == "uerr" {
|
||||
var uver string = repo.GetUserVersion()
|
||||
if uver == "uerr" {
|
||||
// blank these out
|
||||
uhort = ""
|
||||
uver = ""
|
||||
}
|
||||
var lasttag string = repo.GetLastTag()
|
||||
var thort string = repo.GetTargetVersion()
|
||||
|
@ -252,15 +169,16 @@ func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) {
|
|||
}
|
||||
|
||||
if repo.IsDirty() {
|
||||
age = "#"
|
||||
age = ""
|
||||
uver = "* " + uver
|
||||
end += "(dirty) "
|
||||
}
|
||||
|
||||
var args []string
|
||||
if full {
|
||||
args = []string{cname, age, mhort, dhort, uhort, chort, lasttag, thort, rtype, gopath}
|
||||
args = []string{cname, age, uver, dhort, mhort, chort, lasttag, thort, rtype, gopath}
|
||||
} else {
|
||||
args = []string{gopath, cname, age, mhort, dhort, uhort, chort, lasttag, thort, rtype}
|
||||
args = []string{gopath, cname, age, uver, dhort, mhort, chort, lasttag, thort, rtype}
|
||||
}
|
||||
start := cobol.StandardTableSize10(sizes, args)
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ func (p *Patchset) addPatchFiles(repo *gitpb.Repo) error {
|
|||
patch.Filename, _ = filepath.Rel(p.TmpDir, path)
|
||||
patch.Data = data
|
||||
patch.parseData()
|
||||
patch.StartHash = repo.DevelHash()
|
||||
patch.StartHash = repo.ActualDevelHash()
|
||||
patch.NewHash = "na"
|
||||
patch.Namespace = repo.GetGoPath()
|
||||
if p.Patches == nil {
|
||||
|
|
Loading…
Reference in New Issue