diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go index 291179f..40b304c 100644 --- a/cmd/gotop/main.go +++ b/cmd/gotop/main.go @@ -335,6 +335,7 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) { // TODO: Abstract out the UI toolkit. mum4k/termdash, VladimirMarkelov/clui, gcla/gowid, rivo/tview, marcusolsson/tui-go might work better for some OS/Archs. Performance/memory use comparison would be interesting. // TODO: all of the go vet stuff, more unit tests, benchmarks, finish remote. // TODO: color bars for memory, a-la bashtop +// TODO: add verbose debugging option func main() { // For performance testing //go func() { @@ -376,6 +377,14 @@ func run() int { } defer logfile.Close() + errs := devices.Startup(conf.ExtensionVars) + if len(errs) > 0 { + for _, err := range errs { + stderrLogger.Print(err) + } + return 1 + } + lstream, err := getLayout(conf) if err != nil { stderrLogger.Print(err) @@ -387,13 +396,6 @@ func run() int { return runTests(conf) } - errs := devices.Startup(conf.ExtensionVars) - if len(errs) > 0 { - for _, err := range errs { - stderrLogger.Print(err) - } - return 1 - } if err = ui.Init(); err != nil { stderrLogger.Print(err) return 1 diff --git a/devices/devices.go b/devices/devices.go index a804fab..c3cad42 100644 --- a/devices/devices.go +++ b/devices/devices.go @@ -30,7 +30,10 @@ func RegisterStartup(f func(vars map[string]string) error) { _startup = append(_startup, f) } -// Called after configuration has been parsed +// Startup is after configuration has been parsed, and provides extensions with +// any configuration data provided by the user. An extension's registered +// startup function should process and populate data at least once so that the +// widgets have a full list of sensors, for (e.g.) setting up colors. func Startup(vars map[string]string) []error { rv := make([]error, 0) for _, f := range _startup { diff --git a/termui/linegraph.go b/termui/linegraph.go index fd50520..55aacbd 100644 --- a/termui/linegraph.go +++ b/termui/linegraph.go @@ -61,6 +61,7 @@ func (self *LineGraph) Draw(buf *Buffer) { seriesLineColor, ok := self.LineColors[seriesName] if !ok { seriesLineColor = self.DefaultLineColor + self.LineColors[seriesName] = seriesLineColor } // coordinates of last point