diff options
Diffstat (limited to 'human.go')
| -rw-r--r-- | human.go | 35 |
1 files changed, 30 insertions, 5 deletions
@@ -1,6 +1,11 @@ package forgepb -import "fmt" +import ( + "fmt" + "os" + + "go.wit.com/log" +) // mostly just functions related to making STDOUT // more readable by us humans @@ -13,14 +18,34 @@ func RepoHeader() string { return "Name Path" } -func (all *Repos) StandardHeader() string { +func standardHeader() string { return fmt.Sprintf("%-4s %40s %s", "r/w", "Path", "flags") } -func (r *Repo) StandardHeader() string { +func (all *Repos) standardHeader(r *Repo) string { var flags string - if r.Private { + var readonly string + if all.IsPrivate(r.GoPath) { flags += "(private) " } - return fmt.Sprintf("%-4s %40s %s", "true", r.GoPath, flags) + if all.IsReadOnly(r.GoPath) { + readonly = "" + } else { + readonly = "r/w" + } + return fmt.Sprintf("%-4s %-40s %s", readonly, r.GoPath, flags) +} + +// print a human readable table to STDOUT +func (all *Repos) PrintTable() { + if all == nil { + log.Info("WTF") + os.Exit(0) + } + log.Info(standardHeader()) + loop := all.SortByPath() + for loop.Scan() { + r := loop.Repo() + log.Info(all.standardHeader(r)) + } } |
