Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #18 from meltwater/addVersion
Browse files Browse the repository at this point in the history
Added command: version
  • Loading branch information
mikljohansson committed Mar 14, 2017
2 parents e7e9196 + 8168257 commit ca56ce1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export GO15VENDOREXPERIMENT=1
VERSION := $(shell git describe --tags)

all: tools deps fmt build test lint

Expand All @@ -15,7 +16,8 @@ fmt:
go fmt ./...

build:
CGO_ENABLED=0 go build -o "secretary-`uname -s`-`uname -m`"
CGO_ENABLED=0 go build -o "secretary-`uname -s`-`uname -m`" \
-ldflags "-X main.version=${VERSION}"
ln -sf "secretary-`uname -s`-`uname -m`" secretary

test:
Expand Down
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@ import (
"github.com/spf13/cobra"
)

var version = "undefined"

func main() {
rootCmd := &cobra.Command{Use: "secretary"}

// Version command
{
cmdVersion := &cobra.Command{
Use: "version",
Short: "prints the version of secretary",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}

rootCmd.AddCommand(cmdVersion)
}

// Key generation command
{
var keyPath string
Expand Down

0 comments on commit ca56ce1

Please sign in to comment.