mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-15 20:08:46 +08:00
Add version command to CLI
This commit is contained in:
parent
83c9d5ae94
commit
6cd0ab65a3
@ -17,6 +17,9 @@ import (
|
||||
"github.com/rs/xid"
|
||||
)
|
||||
|
||||
// Version of asynq library and CLI.
|
||||
const Version = "0.10.0"
|
||||
|
||||
// DefaultQueueName is the queue name used if none are specified by user.
|
||||
const DefaultQueueName = "default"
|
||||
|
||||
|
@ -19,13 +19,11 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const version = "v0.10.0" // TODO: Define this version string in a more canonical place.
|
||||
|
||||
// migrateCmd represents the migrate command
|
||||
var migrateCmd = &cobra.Command{
|
||||
Use: "migrate",
|
||||
Short: fmt.Sprintf("Migrate all tasks to be compatible with asynq@%s", version),
|
||||
Long: fmt.Sprintf("Migrate (asynq migrate) will convert all tasks in redis to be compatible with asynq@%s.", version),
|
||||
Short: fmt.Sprintf("Migrate all tasks to be compatible with asynq@%s", base.Version),
|
||||
Long: fmt.Sprintf("Migrate (asynq migrate) will convert all tasks in redis to be compatible with asynq@%s.", base.Version),
|
||||
Run: migrate,
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/hibiken/asynq/internal/base"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
@ -26,9 +27,20 @@ var password string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "asynq",
|
||||
Short: "A monitoring tool for asynq queues",
|
||||
Long: `Asynq is a montoring CLI to inspect tasks and queues managed by asynq.`,
|
||||
Use: "asynq",
|
||||
Short: "A monitoring tool for asynq queues",
|
||||
Long: `Asynq is a montoring CLI to inspect tasks and queues managed by asynq.`,
|
||||
Version: base.Version,
|
||||
}
|
||||
|
||||
var versionOutput = fmt.Sprintf("asynq version %s\n", base.Version)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Print(versionOutput)
|
||||
},
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
@ -43,6 +55,9 @@ func Execute() {
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
rootCmd.SetVersionTemplate(versionOutput)
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file to set flag defaut values (default is $HOME/.asynq.yaml)")
|
||||
rootCmd.PersistentFlags().StringVarP(&uri, "uri", "u", "127.0.0.1:6379", "redis server URI")
|
||||
rootCmd.PersistentFlags().IntVarP(&db, "db", "n", 0, "redis database number (default is 0)")
|
||||
|
Loading…
Reference in New Issue
Block a user