-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.go
51 lines (41 loc) · 978 Bytes
/
view.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"encoding/json"
tm "github.com/buger/goterm"
)
func printRawJSON(backends backendSlice) {
var outstring string
for _, v := range backends {
w, _ := json.Marshal(v)
if v.State == "Went" {
outstring = tm.Color(string(w), tm.YELLOW)
} else {
if v.Happy {
outstring = tm.Color(string(w), tm.GREEN)
} else {
outstring = tm.Color(string(w), tm.RED)
}
}
tm.Println(outstring)
}
}
func printTerse(backends backendSlice) {
var outstring, prev string
for _, v := range backends {
if prev != v.Director {
tm.Printf("\n%25s: ", v.Director)
}
if v.State == "Went" {
outstring = "[" + tm.Color(string(v.Name), tm.YELLOW) + "]\t"
} else {
if v.Happy {
outstring = "[" + tm.Color(string(v.Name), tm.GREEN) + "]\t"
} else {
outstring = "[" + tm.Color(string(v.Name), tm.RED) + "]\t"
}
}
// For some reason I don't know my X position here. Why?
tm.Print(outstring)
prev = v.Director
}
}