2019-01-28 23:09:52 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
ui "github.com/sqshq/termui"
|
|
|
|
"github.com/sqshq/vcmd/config"
|
2019-02-02 04:39:34 +00:00
|
|
|
"github.com/sqshq/vcmd/console"
|
2019-01-31 00:02:38 +00:00
|
|
|
"github.com/sqshq/vcmd/data"
|
2019-02-02 04:39:34 +00:00
|
|
|
"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")
|
2019-02-02 04:39:34 +00:00
|
|
|
csl := console.Console{}
|
|
|
|
csl.Init()
|
|
|
|
defer csl.Close()
|
2019-01-28 23:09:52 +00:00
|
|
|
|
2019-02-02 04:39:34 +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)
|
2019-02-02 04:39:34 +00:00
|
|
|
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 {
|
2019-02-02 04:39:34 +00:00
|
|
|
data.NewPoller(chart, item, chartConfig.RefreshRateMs)
|
2019-01-28 23:09:52 +00:00
|
|
|
}
|
2019-01-31 00:02:38 +00:00
|
|
|
}
|
|
|
|
|
2019-02-02 04:39:34 +00:00
|
|
|
handler := event.Handler{
|
|
|
|
Layout: layout,
|
|
|
|
RenderEvents: time.NewTicker(console.RenderRate).C,
|
|
|
|
ConsoleEvents: ui.PollEvents(),
|
2019-01-28 23:09:52 +00:00
|
|
|
}
|
2019-02-02 04:39:34 +00:00
|
|
|
|
|
|
|
handler.HandleEvents()
|
2019-01-28 23:09:52 +00:00
|
|
|
}
|