Skip to content

Commit

Permalink
Merge pull request #152 from pressly/releases
Browse files Browse the repository at this point in the history
Add `goose --version' & build release binaries
  • Loading branch information
VojtechVitek authored Mar 5, 2019
2 parents e604245 + 6137172 commit e4b9895
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.PHONY: dist
dist:
@mkdir -p ./bin
@rm -f ./bin/*
GOOS=darwin GOARCH=amd64 go build -o ./bin/goose-darwin64 ./cmd/goose
GOOS=linux GOARCH=amd64 go build -o ./bin/goose-linux64 ./cmd/goose
GOOS=linux GOARCH=386 go build -o ./bin/goose-linux386 ./cmd/goose

GOOS=darwin GOARCH=amd64 go build -o ./bin/goose-darwin64 ./cmd/goose
GOOS=linux GOARCH=amd64 go build -o ./bin/goose-linux64 ./cmd/goose
GOOS=linux GOARCH=386 go build -o ./bin/goose-linux386 ./cmd/goose
GOOS=windows GOARCH=amd64 go build -o ./bin/goose-windows64.exe ./cmd/goose
GOOS=windows GOARCH=386 go build -o ./bin/goose-windows386.exe ./cmd/goose
19 changes: 13 additions & 6 deletions cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"database/sql"
"flag"
"fmt"
"log"
"os"

Expand All @@ -13,22 +14,28 @@ var (
flags = flag.NewFlagSet("goose", flag.ExitOnError)
dir = flags.String("dir", ".", "directory with migration files")
verbose = flags.Bool("v", false, "enable verbose mode")
help = flags.Bool("h", false, "print help")
version = flags.Bool("version", false, "print version")
)

func main() {
flags.Usage = usage
flags.Parse(os.Args[1:])

args := flags.Args()
if len(args) == 0 || args[0] == "-h" || args[0] == "--help" {
flags.Usage()
if *version {
fmt.Println(goose.VERSION)
return
}

if *verbose {
goose.SetVerbose(true)
}

args := flags.Args()
if len(args) == 0 || *help {
flags.Usage()
return
}

switch args[0] {
case "create":
if err := goose.Run("create", nil, *dir, args[1:]...); err != nil {
Expand Down Expand Up @@ -82,9 +89,9 @@ func main() {
}

func usage() {
log.Print(usagePrefix)
fmt.Println(usagePrefix)
flags.PrintDefaults()
log.Print(usageCommands)
fmt.Println(usageCommands)
}

var (
Expand Down
2 changes: 2 additions & 0 deletions goose.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"sync"
)

const VERSION = "v2.6.0"

var (
duplicateCheckOnce sync.Once
minVersion = int64(0)
Expand Down

0 comments on commit e4b9895

Please sign in to comment.