Skip to content

Commit

Permalink
add version
Browse files Browse the repository at this point in the history
  • Loading branch information
lyoshenka committed Aug 15, 2018
1 parent 73f3ace commit 5f9db51
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ BINARY=prism-bin

DIR = $(shell cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
VENDOR_DIR = vendor
IMPORT_PATH = github.com/lbryio/reflector.go

VERSION=$(shell git --git-dir=${DIR}/.git describe --dirty --always --long --abbrev=7)
LDFLAGS = -ldflags "-X main.Version=${VERSION}"
VERSION = $(shell git --git-dir=${DIR}/.git describe --dirty --always --long --abbrev=7)
LDFLAGS = -ldflags "-X ${IMPORT_PATH}/meta.Version=${VERSION}"


.PHONY: build dep clean test
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var rootCmd = &cobra.Command{
if conf == "" {
logrus.Errorln("--conf flag required")
os.Exit(1)
} else {
} else if conf != "none" {
globalConfig, err = loadConfig(conf)
if err != nil {
logrus.Error(err)
Expand Down
22 changes: 22 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"log"

"github.com/lbryio/reflector.go/meta"

"github.com/spf13/cobra"
)

func init() {
var cmd = &cobra.Command{
Use: "version",
Short: "Print the version",
Run: versionCmd,
}
rootCmd.AddCommand(cmd)
}

func versionCmd(cmd *cobra.Command, args []string) {
log.Printf("version %s\n", meta.Version)
}
3 changes: 3 additions & 0 deletions meta/meta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package meta

var Version = ""

0 comments on commit 5f9db51

Please sign in to comment.