Skip to content

Commit

Permalink
add version flag!
Browse files Browse the repository at this point in the history
  • Loading branch information
wakeful committed Dec 2, 2017
1 parent 78b7fdf commit 702d2d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

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

BUILD_PLATFORMS="linux darwin"
BUILD_ARCHS="amd64"
Expand Down
15 changes: 15 additions & 0 deletions yaml2json.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ import (
"github.com/go-yaml/yaml"

"encoding/json"
"flag"
"fmt"
"log"
"os"
)

var (
showVersion = flag.Bool("version", false, "show version and exit")
url = "https://github.com/wakeful/yaml2json"
version = "dev"
)

func main() {
flag.Parse()

if *showVersion {
fmt.Printf("yaml2json\n url: %s\n version: %s\n", url, version)
os.Exit(2)
}

input, err := readInput()

if err != nil {
Expand Down

0 comments on commit 702d2d8

Please sign in to comment.