summaryrefslogtreecommitdiff
path: root/tableGolang.go
blob: 364aa7709d42a948903953a5fb88d65e5cd3147b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package forgepb

import (
	"go.wit.com/lib/protobuf/gitpb"
	"go.wit.com/log"
)

func (f *Forge) PrintGolangTB(pb *gitpb.Repos) string {
	pb.SortByUserVersion()
	tablePB := f.makeDefaultTB(pb)
	tablePB.PrintTable()
	var dirty int
	var writable int
	var bins int
	var protos int
	for repo := range pb.IterAll() {
		if repo.IsDirty() {
			dirty += 1
		}
		if repo.IsBinary() {
			bins += 1
		}
		if repo.IsProtobuf() {
			protos += 1
		}
		if f.Config.IsWritable(repo.Namespace) {
			writable += 1
		}
	}
	return log.Sprintf("f.GolangRepos:  total=(%d)   dirty=(%d)  writable=(%d)  binaries=(%d)  protobufs(%d)", pb.Len(), dirty, writable, bins, protos)
}

func (f *Forge) makeGolangTB(pb *gitpb.Repos) *gitpb.ReposTable {
	t := f.makeDefaultBaseTB(pb)
	var col *gitpb.RepoFunc

	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.AddState()
	col.Width = 12

	col = t.AddURL()
	col.Width = -1
	return t
}