Skip to content

Commit 702d2d8

Browse files
committed
add version flag!
1 parent 78b7fdf commit 702d2d8

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
VERSION=$(git describe --tags --dirty)
55
GO_BUILD_CMD="go build -a -installsuffix cgo"
6-
GO_BUILD_LDFLAGS="-s -w"
6+
GO_BUILD_LDFLAGS="-s -w -X main.version=$VERSION"
77

88
BUILD_PLATFORMS="linux darwin"
99
BUILD_ARCHS="amd64"

yaml2json.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@ import (
44
"github.com/go-yaml/yaml"
55

66
"encoding/json"
7+
"flag"
78
"fmt"
89
"log"
10+
"os"
11+
)
12+
13+
var (
14+
showVersion = flag.Bool("version", false, "show version and exit")
15+
url = "https://github.com/wakeful/yaml2json"
16+
version = "dev"
917
)
1018

1119
func main() {
20+
flag.Parse()
21+
22+
if *showVersion {
23+
fmt.Printf("yaml2json\n url: %s\n version: %s\n", url, version)
24+
os.Exit(2)
25+
}
26+
1227
input, err := readInput()
1328

1429
if err != nil {

0 commit comments

Comments
 (0)