Skip to content

Commit

Permalink
Implement basic version cmd for basecoind
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Brink committed Jan 29, 2018
1 parent 0b5c262 commit a1e8cc7
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ ci: get_tools get_vendor_deps build test_cover
### Build

build:
@rm -rf examples/basecoin/vendor/
go build $(BUILD_FLAGS) -o build/basecoin ./examples/basecoin/cmd/...
cd examples/basecoin && $(MAKE) build

dist:
@bash publish/dist.sh
Expand All @@ -32,6 +31,7 @@ get_vendor_deps:
@rm -rf vendor/
@echo "--> Running glide install"
@glide install
cd examples/basecoin && $(MAKE) get_vendor_deps

draw_deps:
@# requires brew install graphviz or apt-get install graphviz
Expand All @@ -56,7 +56,6 @@ TUTORIALS=$(shell find docs/guide -name "*md" -type f)
test: test_unit # test_cli

test_unit:
@rm -rf examples/basecoin/vendor/
@go test $(PACKAGES)

test_cover:
Expand Down
27 changes: 26 additions & 1 deletion examples/basecoin/cmd/basecoind/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,33 @@ package main

import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/tendermint/tmlibs/cli"

"github.com/cosmos/cosmos-sdk/examples/basecoin/version"
)

var rootCmd = &cobra.Command{
Use: "basecoind",
Short: "The basecoin daemon.",
}

var versionCmd = &cobra.Command{
Use: "version",
Short: "Show version info for basecoind.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
}

func main() {
fmt.Println("TODO: move examples/basecoin/main.go here and refactor")
rootCmd.AddCommand(
versionCmd,
)

cmd := cli.PrepareMainCmd(rootCmd, "BC", os.ExpandEnv("$HOME/.basecoind"))
cmd.Execute()
}
5 changes: 5 additions & 0 deletions examples/basecoin/glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ package: github.com/cosmos/cosmos-sdk/examples/basecoin
import:
- package: github.com/cosmos/cosmos-sdk
version: develop
- package: github.com/spf13/cobra
version: v0.0.1
- package: github.com/tendermint/tmlibs
subpackages:
- cli
17 changes: 17 additions & 0 deletions examples/basecoin/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package version

const Maj = "0"
const Min = "7"
const Fix = "0"

var (
Version = "0.7.0"

GitCommit string
)

func init() {
if GitCommit != "" {
Version += "-" + GitCommit
}
}
12 changes: 11 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ const Maj = "0"
const Min = "7"
const Fix = "1"

const Version = "0.7.1"
var (
Version = "0.7.1"

GitCommit string
)

func init() {
if GitCommit != "" {
Version += "-" + GitCommit
}
}

0 comments on commit a1e8cc7

Please sign in to comment.