summaryrefslogtreecommitdiff
path: root/tableConfigs.go
blob: 1bbc95b5915f4393aecf1dd6aa2f31e8fc64c742 (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
59
60
61
62
63
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package forgepb

import (
	"go.wit.com/log"
)

// returns footer
func (pb *ForgeConfigs) PrintTable() string {
	if pb == nil {
		return "pb was nil"
	}
	tablePB := pb.MakeTable()
	tablePB.PrintTable()
	return log.Sprintf("forge Configs DefaultTable: %d entries", pb.Len())
}

func (pb *ForgeConfigs) MakeTable() *ForgeConfigsTable {
	t := pb.NewTable("tagList")
	t.NewUuid()

	//	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
}