sampler-fork/main.go

40 lines
895 B
Go
Raw Normal View History

2019-01-28 23:09:52 +00:00
package main
import (
ui "github.com/sqshq/termui"
"github.com/sqshq/vcmd/config"
"github.com/sqshq/vcmd/console"
2019-01-31 00:02:38 +00:00
"github.com/sqshq/vcmd/data"
"github.com/sqshq/vcmd/event"
2019-01-28 23:09:52 +00:00
"github.com/sqshq/vcmd/widgets"
"time"
)
func main() {
cfg := config.Load("/Users/sqshq/Go/src/github.com/sqshq/vcmd/config.yml")
csl := console.Console{}
csl.Init()
defer csl.Close()
2019-01-28 23:09:52 +00:00
layout := widgets.NewLayout(ui.TerminalDimensions())
2019-01-30 00:21:57 +00:00
2019-01-31 01:41:51 +00:00
for _, chartConfig := range cfg.RunCharts {
2019-01-28 23:09:52 +00:00
2019-01-31 01:41:51 +00:00
chart := widgets.NewRunChart(chartConfig.Title)
layout.AddComponent(chart, chartConfig.Position, chartConfig.Size, widgets.TypeRunChart)
2019-01-28 23:09:52 +00:00
2019-01-31 23:40:05 +00:00
for _, item := range chartConfig.Items {
data.NewPoller(chart, item, chartConfig.RefreshRateMs)
2019-01-28 23:09:52 +00:00
}
2019-01-31 00:02:38 +00:00
}
handler := event.Handler{
Layout: layout,
RenderEvents: time.NewTicker(console.RenderRate).C,
ConsoleEvents: ui.PollEvents(),
2019-01-28 23:09:52 +00:00
}
handler.HandleEvents()
2019-01-28 23:09:52 +00:00
}