From 193881ffb0abd0d7fa4e8e68d692ee1ae6fbfad8 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Fri, 27 May 2022 15:01:34 -0700 Subject: [PATCH] (cli): Define styles in global scope --- tools/asynq/cmd/dash/dash.go | 2 -- tools/asynq/cmd/dash/draw.go | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/asynq/cmd/dash/dash.go b/tools/asynq/cmd/dash/dash.go index f1506ee..422550c 100644 --- a/tools/asynq/cmd/dash/dash.go +++ b/tools/asynq/cmd/dash/dash.go @@ -64,8 +64,6 @@ type Options struct { PollInterval time.Duration } -var baseStyle = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset) - func Run(opts Options) { s, err := tcell.NewScreen() if err != nil { diff --git a/tools/asynq/cmd/dash/draw.go b/tools/asynq/cmd/dash/draw.go index 8fea400..a4552bc 100644 --- a/tools/asynq/cmd/dash/draw.go +++ b/tools/asynq/cmd/dash/draw.go @@ -18,6 +18,11 @@ import ( "github.com/mattn/go-runewidth" ) +var ( + baseStyle = tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset) + labelStyle = baseStyle.Foreground(tcell.ColorLightGray) +) + // drawer draws UI with the given state. type drawer interface { Draw(state *State) @@ -259,7 +264,6 @@ func drawQueueSummary(d *ScreenDrawer, state *State) { d.Println("ERROR: Press q to go back", baseStyle) return } - labelStyle := baseStyle.Foreground(tcell.ColorLightGray) d.Print("Name: ", labelStyle) d.Println(q.Queue, baseStyle) d.Print("Size: ", labelStyle)