2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-26 07:42:17 +08:00

Add flags to stats command

This commit is contained in:
Ken Hibino 2019-12-06 07:36:08 -08:00
parent b749d8bd34
commit 62fb3cf7d9

View File

@ -12,6 +12,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// Flags
var uri string
var db int
// statsCmd represents the stats command // statsCmd represents the stats command
var statsCmd = &cobra.Command{ var statsCmd = &cobra.Command{
Use: "stats", Use: "stats",
@ -39,12 +43,15 @@ func init() {
// Cobra supports local flags which will only run when this command // Cobra supports local flags which will only run when this command
// is called directly, e.g.: // is called directly, e.g.:
// statsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") // statsCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
statsCmd.Flags().StringVarP(&uri, "uri", "u", "127.0.0.1:6379", "Redis server URI")
statsCmd.Flags().IntVarP(&db, "db", "n", 0, "Redis database number")
} }
func stats(cmd *cobra.Command, args []string) { func stats(cmd *cobra.Command, args []string) {
c := redis.NewClient(&redis.Options{ c := redis.NewClient(&redis.Options{
Addr: "localhost:6379", Addr: uri,
DB: 2, DB: db,
}) })
r := rdb.NewRDB(c) r := rdb.NewRDB(c)