Skip to content

Commit 8f35981

Browse files
Merge pull request #50 from vishwas-tw/master
Adding a version flag to talisman
2 parents 664bfb2 + 9503eca commit 8f35981

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

build

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
2-
gox -os="linux darwin windows" -arch="386 amd64" -ldflags "-X main.Version=$(git describe --tags HEAD)"
3-
shasum -b -a256 talisman_{l,d,w}* > checksums
2+
VERSION=$(git describe --tags HEAD)
3+
gox -os="linux darwin windows" -arch="386 amd64" -ldflags="-X main.Version=${VERSION}"
4+
shasum -b -a256 talisman_{l,d,w}* > checksums

talisman.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bufio"
55
"flag"
6+
"fmt"
67
"io"
78
"os"
89
"strings"
@@ -14,6 +15,8 @@ import (
1415
var (
1516
fdebug bool
1617
githook string
18+
showVersion bool
19+
Version string = "Development Build"
1720
)
1821

1922
const (
@@ -34,9 +37,16 @@ type Options struct {
3437
func main() {
3538
flag.BoolVar(&fdebug, "debug", false, "enable debug mode (warning: very verbose)")
3639
flag.BoolVar(&fdebug, "d", false, "short form of debug (warning: very verbose)")
40+
flag.BoolVar(&showVersion, "v", false, "show current version of talisman" )
41+
flag.BoolVar(&showVersion, "version", false, "show current version of talisman")
3742
flag.StringVar(&githook, "githook", PrePush, "either pre-push or pre-commit")
3843
flag.Parse()
3944

45+
if showVersion {
46+
fmt.Printf("talisman %s\n", Version)
47+
os.Exit(0)
48+
}
49+
4050
options := Options{
4151
debug: fdebug,
4252
githook: githook,
@@ -56,7 +66,7 @@ func run(stdin io.Reader, options Options) (returnCode int) {
5666
options.githook = PrePush
5767
}
5868

59-
log.Info("Running %s hook", options.githook)
69+
log.Infof("Running %s hook", options.githook)
6070

6171
var additions []git_repo.Addition
6272
if options.githook == PreCommit {

0 commit comments

Comments
 (0)