-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.go
66 lines (57 loc) · 1.03 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
ui "github.com/gtfierro/termui"
"github.com/urfave/cli"
"os"
)
var vk string
func main() {
app := cli.NewApp()
app.Name = "hvacdash"
app.Version = "0.0.1"
app.Usage = "HVAC Dashboard"
app.Action = run
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "entity,e",
Value: "",
Usage: "The entity to use",
EnvVar: "BW2_DEFAULT_ENTITY",
},
cli.StringFlag{
Name: "agent,a",
Usage: "Local agent address",
EnvVar: "BW2_AGENT",
},
cli.StringFlag{
Name: "hod",
Usage: "HodDB base uri",
Value: "ciee/hod",
},
}
app.Run(os.Args)
}
func run(c *cli.Context) error {
d := newDash(c)
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
rows, zonebufs := d.GetZones()
ui.Body.AddRows(rows...)
ui.Handle("/sys/kbd/q", func(ui.Event) {
// press q to quit
ui.StopLoop()
})
draw := func(t int) {
ui.Body.Align()
ui.Render(zonebufs...)
}
ui.Handle("/timer/1s", func(e ui.Event) {
t := e.Data.(ui.EvtTimer)
draw(int(t.Count))
})
ui.Loop()
return nil
}