forked from projecteru2/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.go
37 lines (31 loc) · 936 Bytes
/
core.go
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
package describe
import (
"os"
"github.com/jedib0t/go-pretty/v6/table"
corepb "github.com/projecteru2/core/rpc/gen"
)
// Core function will describe a coreinfo
// output format can be json or yaml or table
func Core(info *corepb.CoreInfo) {
switch {
case isJSON():
describeAsJSON(info)
case isYAML():
describeAsYAML(info)
default:
describeCore(info)
}
}
func describeCore(info *corepb.CoreInfo) {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"Name", "Description"})
nameRow := []string{"Version", "Git hash", "Built", "Golang version", "OS/Arch", "Identifier"}
// this stupid Revison typo thing is driving my crazy!!!!!!!!!!!!!!!
descRow := []string{info.Version, info.Revison, info.BuildAt, info.GolangVersion, info.OsArch, info.Identifier}
rows := [][]string{nameRow, descRow}
t.AppendRows(toTableRows(rows))
t.AppendSeparator()
t.SetStyle(table.StyleLight)
t.Render()
}