From 5f47379e76904d0aa9c595d5538f4aadd60f1669 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Fri, 27 May 2022 12:26:02 -0700 Subject: [PATCH] (cli): Add --refresh flag to dash command --- tools/asynq/cmd/dash.go | 13 +++++++++---- tools/asynq/cmd/dash/dash.go | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/asynq/cmd/dash.go b/tools/asynq/cmd/dash.go index 92ecd77..460073a 100644 --- a/tools/asynq/cmd/dash.go +++ b/tools/asynq/cmd/dash.go @@ -5,18 +5,22 @@ package cmd import ( + "time" + "github.com/MakeNowJust/heredoc/v2" "github.com/hibiken/asynq/tools/asynq/cmd/dash" "github.com/spf13/cobra" ) var ( - flagDebug = false - flagUseRealData = false + flagDebug = false + flagUseRealData = false + flagPollInterval = 8 * time.Second ) func init() { rootCmd.AddCommand(dashCmd) + dashCmd.Flags().DurationVar(&flagPollInterval, "refresh", 8*time.Second, "Interval between data refresh") // TODO: Remove this debug once we're done dashCmd.Flags().BoolVar(&flagDebug, "debug", false, "Print debug info") dashCmd.Flags().BoolVar(&flagUseRealData, "realdata", true, "Use real data in redis") @@ -30,8 +34,9 @@ var dashCmd = &cobra.Command{ Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { dash.Run(dash.Options{ - DebugMode: flagDebug, - UseRealData: flagUseRealData, + DebugMode: flagDebug, + UseRealData: flagUseRealData, + PollInterval: flagPollInterval, }) }, } diff --git a/tools/asynq/cmd/dash/dash.go b/tools/asynq/cmd/dash/dash.go index 5d16660..d18e5dc 100644 --- a/tools/asynq/cmd/dash/dash.go +++ b/tools/asynq/cmd/dash/dash.go @@ -77,7 +77,6 @@ func Run(opts Options) { os.Exit(1) } s.SetStyle(baseStyle) // set default text style - opts.PollInterval = 2 * time.Second var ( state = State{} // confined in this goroutine only; DO NOT SHARE