add version cmd (Refs #124)

This commit is contained in:
Anton Kaliaev
2017-11-08 17:18:42 -05:00
parent c9612f094b
commit ecb1f02f77

View File

@ -15,6 +15,7 @@ import (
"github.com/tendermint/abci/example/dummy" "github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server" "github.com/tendermint/abci/server"
"github.com/tendermint/abci/types" "github.com/tendermint/abci/types"
"github.com/tendermint/abci/version"
cmn "github.com/tendermint/tmlibs/common" cmn "github.com/tendermint/tmlibs/common"
"github.com/tendermint/tmlibs/log" "github.com/tendermint/tmlibs/log"
@ -71,8 +72,9 @@ var RootCmd = &cobra.Command{
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
switch cmd.Use { switch cmd.Use {
// for the examples apps, don't pre-run case "counter", "dummy": // for the examples apps, don't pre-run
case "counter", "dummy": return nil
case "version": // skip running for version command
return nil return nil
} }
@ -130,6 +132,7 @@ func addCommands() {
RootCmd.AddCommand(deliverTxCmd) RootCmd.AddCommand(deliverTxCmd)
RootCmd.AddCommand(checkTxCmd) RootCmd.AddCommand(checkTxCmd)
RootCmd.AddCommand(commitCmd) RootCmd.AddCommand(commitCmd)
RootCmd.AddCommand(versionCmd)
addQueryFlags() addQueryFlags()
RootCmd.AddCommand(queryCmd) RootCmd.AddCommand(queryCmd)
@ -219,6 +222,17 @@ var commitCmd = &cobra.Command{
}, },
} }
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print abci console version",
Long: "",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println(version.Version)
return nil
},
}
var queryCmd = &cobra.Command{ var queryCmd = &cobra.Command{
Use: "query", Use: "query",
Short: "Query the application state", Short: "Query the application state",