From 0deb04cc9cfa1b25f90730105909c0b10e4658fe Mon Sep 17 00:00:00 2001 From: Beatriz Vieira Date: Wed, 4 Dec 2019 20:18:38 -0300 Subject: [PATCH] feat: add version on command usage --- Makefile | 4 +++- cmd/git-sv/main.go | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1db328c..438574b 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,12 @@ BIN = git-sv ECHOFLAGS ?= +VERSION ?= + BUILDOS ?= linux BUILDARCH ?= amd64 BUILDENVS ?= CGO_ENABLED=0 GOOS=$(BUILDOS) GOARCH=$(BUILDARCH) -BUILDFLAGS ?= -a -installsuffix cgo --ldflags '-extldflags "-lm -lstdc++ -static"' +BUILDFLAGS ?= -a -installsuffix cgo --ldflags '-X main.Version=$(VERSION) -extldflags "-lm -lstdc++ -static"' usage: Makefile @echo $(ECHOFLAGS) "to use make call:" diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index cb1e264..6e8e8da 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -8,6 +8,9 @@ import ( "github.com/urfave/cli" ) +// Version for git-sv +var Version = "" + func main() { cfg := loadConfig() @@ -17,6 +20,7 @@ func main() { app := cli.NewApp() app.Name = "sv" + app.Version = Version app.Usage = "semantic version for git" app.Commands = []cli.Command{ {