Skip to content

Commit

Permalink
Add version sub command.
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Apr 5, 2018
1 parent 4f14cbb commit 1e01d4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ DATE := $(shell date +%Y-%m-%dT%H:%M:%S%z)
.PHONY: test get-deps get-deps-amd64 binary install clean

cmd/ecspresso/ecspresso: *.go cmd/ecspresso/*.go
cd cmd/ecspresso && go build -ldflags "-s -w -X main.version=${GIT_VER} -X main.buildDate=${DATE}" -gcflags="-trimpath=${PWD}"
cd cmd/ecspresso && go build -ldflags "-s -w -X main.Version=${GIT_VER} -X main.buildDate=${DATE}" -gcflags="-trimpath=${PWD}"

install: cmd/ecspresso/ecspresso
install cmd/ecspresso/ecspresso ${GOPATH}/bin
Expand Down
11 changes: 10 additions & 1 deletion cmd/ecspresso/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"log"
"os"

Expand All @@ -9,12 +10,16 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var Version = "current"

func main() {
os.Exit(_main())
}

func _main() int {
conf := kingpin.Flag("config", "config file").Required().String()
kingpin.Command("version", "show version")

conf := kingpin.Flag("config", "config file").String()

deploy := kingpin.Command("deploy", "deploy service")
deployOption := ecspresso.DeployOption{
Expand Down Expand Up @@ -54,6 +59,10 @@ func _main() int {
}

sub := kingpin.Parse()
if sub == "version" {
fmt.Println("ecspresso", Version)
return 0
}

c := ecspresso.NewDefaultConfig()
if err := config.Load(c, *conf); err != nil {
Expand Down

0 comments on commit 1e01d4b

Please sign in to comment.