Extract version command to common location

This commit is contained in:
Ethan Frey 2018-02-14 18:57:48 +01:00 committed by rigelrozanski
parent d1fc3d6801
commit a99d913982
4 changed files with 9 additions and 34 deletions

View File

@ -7,6 +7,8 @@ import (
"github.com/spf13/cobra"
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/version"
)
const (
@ -66,7 +68,7 @@ func main() {
serveCommand(),
KeyCommands(),
lineBreak,
VersionCmd,
version.VersionCmd,
)
// prepare and add flags

View File

@ -9,6 +9,7 @@ import (
"github.com/tendermint/tmlibs/cli"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/version"
)
const (
@ -35,7 +36,7 @@ func main() {
AddNodeCommands(gaiadCmd, node)
gaiadCmd.AddCommand(
VersionCmd,
version.VersionCmd,
)
// prepare and add flags

View File

@ -1,26 +0,0 @@
package main
import (
"fmt"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/version"
)
var (
// VersionCmd prints out the current sdk version
VersionCmd = &cobra.Command{
Use: "version",
Short: "Print the app version",
Run: doVersionCmd,
}
)
func doVersionCmd(cmd *cobra.Command, args []string) {
v := version.Version
if version.GitCommit != "" {
v = v + " " + version.GitCommit
}
fmt.Println(v)
}

View File

@ -1,11 +1,9 @@
package main
package version
import (
"fmt"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/version"
)
var (
@ -18,9 +16,9 @@ var (
)
func doVersionCmd(cmd *cobra.Command, args []string) {
v := version.Version
if version.GitCommit != "" {
v = v + " " + version.GitCommit
v := Version
if GitCommit != "" {
v = v + " " + GitCommit
}
fmt.Println(v)
}