diff --git a/data.go b/data.go index 368edb7..aac74ad 100644 --- a/data.go +++ b/data.go @@ -6,12 +6,14 @@ import "time" type UIData struct { Services []*Service Vars []VarName + UITheme string LastTimestamp time.Time } // NewUIData inits and return new data object. -func NewUIData(vars []VarName) *UIData { +func NewUIData(vars []VarName, theme string) *UIData { return &UIData{ - Vars: vars, + Vars: vars, + UITheme: theme, } } diff --git a/main.go b/main.go index 9a5cd77..e44c7b5 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ var ( dummy = flag.Bool("dummy", false, "Use dummy (console) output") self = flag.Bool("self", false, "Monitor itself") endpoint = flag.String("endpoint", DefaultEndpoint, "URL endpoint for expvars") + uiTheme = flag.String("theme", "dark", "UI color theme. Possible values: dark, default.") ) func main() { @@ -52,7 +53,7 @@ func main() { } // Init UIData - data := NewUIData(vars) + data := NewUIData(vars, ParseUiTheme(*uiTheme)) for _, port := range ports { service := NewService(port, vars) data.Services = append(data.Services, service) diff --git a/ui_multi.go b/ui_multi.go index 2c7f920..0130679 100644 --- a/ui_multi.go +++ b/ui_multi.go @@ -24,7 +24,7 @@ func (t *TermUI) Init(data UIData) error { return err } - termui.UseTheme("helloworld") + termui.UseTheme(data.UITheme) t.Title = func() *termui.Par { p := termui.NewPar("") diff --git a/ui_single.go b/ui_single.go index 208e49b..46e9d2a 100644 --- a/ui_single.go +++ b/ui_single.go @@ -25,7 +25,7 @@ func (t *TermUISingle) Init(data UIData) error { t.Sparklines = make(map[VarName]*termui.Sparkline) - termui.UseTheme("helloworld") + termui.UseTheme(data.UITheme) t.Title = func() *termui.Par { p := termui.NewPar("") diff --git a/utils.go b/utils.go index 8e4c935..39b1d49 100644 --- a/utils.go +++ b/utils.go @@ -12,6 +12,14 @@ import ( var ErrParsePorts = fmt.Errorf("cannot parse ports argument") +func ParseUiTheme(theme string) string { + t := "" + if theme == "dark" { + t = "helloworld" + } + return t +} + // ParseVars returns parsed and validated slice of strings with // variables names that will be used for monitoring. func ParseVars(vars string) ([]VarName, error) {