diff --git a/Makefile b/Makefile index 30b1e589a..b4fbf32ae 100644 --- a/Makefile +++ b/Makefile @@ -3,14 +3,16 @@ GOTOOLS = github.com/mitchellh/gox \ github.com/rigelrozanski/shelldown/cmd/shelldown TUTORIALS=$(shell find docs/guide -name "*md" -type f) +LINKER_FLAGS:="-X github.com/tendermint/basecoin/client/commands.CommitHash=`git rev-parse --short HEAD`" + all: get_vendor_deps install test build: @go build ./cmd/... install: - @go install ./cmd/... - @go install ./docs/guide/counter/cmd/... + @go install -ldflags $(LINKER_FLAGS) ./cmd/... + @go install -ldflags $(LINKER_FLAGS) ./docs/guide/counter/cmd/... dist: @bash publish/dist.sh diff --git a/client/commands/version.go b/client/commands/version.go index 9ffa6b36d..34a2af2ff 100644 --- a/client/commands/version.go +++ b/client/commands/version.go @@ -7,11 +7,14 @@ import ( "github.com/tendermint/basecoin/version" ) +// CommitHash should be filled by linker flags +var CommitHash = "" + // VersionCmd - command to show the application version var VersionCmd = &cobra.Command{ Use: "version", Short: "Show version info", Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.Version) + fmt.Printf("v%s %s\n", version.Version, CommitHash) }, } diff --git a/cmd/basecoin/commands/version.go b/cmd/basecoin/commands/version.go deleted file mode 100644 index b45addae8..000000000 --- a/cmd/basecoin/commands/version.go +++ /dev/null @@ -1,29 +0,0 @@ -package commands - -import ( - "fmt" - - "github.com/spf13/cobra" - - "github.com/tendermint/basecoin/version" -) - -// VersionCmd - command to show the application version -var VersionCmd = &cobra.Command{ - Use: "version", - Short: "Show version info", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version.Version) - }, -} - -// QuickVersionCmd - returns a version command based on version input -func QuickVersionCmd(version string) *cobra.Command { - return &cobra.Command{ - Use: "version", - Short: "Show version info", - Run: func(cmd *cobra.Command, args []string) { - fmt.Println(version) - }, - } -} diff --git a/cmd/basecoin/main.go b/cmd/basecoin/main.go index b99482e1d..fc4fa691a 100644 --- a/cmd/basecoin/main.go +++ b/cmd/basecoin/main.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tmlibs/cli" "github.com/tendermint/basecoin" + client "github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/modules/auth" "github.com/tendermint/basecoin/modules/base" @@ -51,7 +52,7 @@ func main() { commands.StartCmd, //commands.RelayCmd, commands.UnsafeResetAllCmd, - commands.VersionCmd, + client.VersionCmd, ) cmd := cli.PrepareMainCmd(rt, "BC", os.ExpandEnv("$HOME/.basecoin")) diff --git a/cmd/baseserver/main.go b/cmd/baseserver/main.go index 27cb14b8c..fee1552a3 100644 --- a/cmd/baseserver/main.go +++ b/cmd/baseserver/main.go @@ -74,11 +74,12 @@ func main() { srvCli.AddCommand( commands.InitCmd, + commands.VersionCmd, serveCmd, ) - // TODO: Decide whether to use $HOME/.basecli for compatibility - // or just use $HOME/.baseserver? + // this should share the dir with basecli, so you can use the cli and + // the api interchangeably cmd := cli.PrepareMainCmd(srvCli, "BC", os.ExpandEnv("$HOME/.basecli")) if err := cmd.Execute(); err != nil { log.Fatal(err) diff --git a/cmd/eyes/main.go b/cmd/eyes/main.go index b915b09e9..c82cd7d19 100644 --- a/cmd/eyes/main.go +++ b/cmd/eyes/main.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tmlibs/cli" "github.com/tendermint/basecoin" + client "github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/modules/base" "github.com/tendermint/basecoin/modules/eyes" @@ -36,7 +37,7 @@ func main() { InitCmd, commands.StartCmd, commands.UnsafeResetAllCmd, - commands.VersionCmd, + client.VersionCmd, ) cmd := cli.PrepareMainCmd(rt, "EYE", os.ExpandEnv("$HOME/.eyes")) diff --git a/docs/guide/counter/cmd/counter/main.go b/docs/guide/counter/cmd/counter/main.go index 37816b042..705136964 100644 --- a/docs/guide/counter/cmd/counter/main.go +++ b/docs/guide/counter/cmd/counter/main.go @@ -7,6 +7,7 @@ import ( "github.com/tendermint/tmlibs/cli" + client "github.com/tendermint/basecoin/client/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/docs/guide/counter/plugins/counter" ) @@ -24,7 +25,7 @@ func main() { commands.InitCmd, commands.StartCmd, commands.UnsafeResetAllCmd, - commands.VersionCmd, + client.VersionCmd, ) cmd := cli.PrepareMainCmd(RootCmd, "CT", os.ExpandEnv("$HOME/.counter")) diff --git a/docs/guide/counter/cmd/countercli/main.go b/docs/guide/counter/cmd/countercli/main.go index 37afba1d4..975fb5655 100644 --- a/docs/guide/counter/cmd/countercli/main.go +++ b/docs/guide/counter/cmd/countercli/main.go @@ -70,6 +70,7 @@ func main() { BaseCli.AddCommand( commands.InitCmd, commands.ResetCmd, + commands.VersionCmd, keycmd.RootCmd, seeds.RootCmd, query.RootCmd,