Skip to content

Commit

Permalink
Add a --version flag that goreleaser will populate for us
Browse files Browse the repository at this point in the history
  • Loading branch information
glenjamin committed Apr 2, 2019
1 parent 4caef0e commit 66227f6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions main.go
Expand Up @@ -15,6 +15,8 @@ import (
"gotest.tools/gotestsum/testjson"
)

var version = "master"

func main() {
name := os.Args[0]
flags, opts := setupFlags(name)
Expand All @@ -29,6 +31,11 @@ func main() {
opts.args = flags.Args()
setupLogging(opts)

if opts.version {
fmt.Fprintf(os.Stdout, "gotestsum version %s\n", version)
os.Exit(0)
}

switch err := run(opts).(type) {
case nil:
case *exec.ExitError:
Expand Down Expand Up @@ -76,6 +83,7 @@ Formats:
flags.BoolVar(&opts.noColor, "no-color", false, "disable color output")
flags.Var(opts.noSummary, "no-summary",
fmt.Sprintf("do not print summary of: %s", testjson.SummarizeAll.String()))
flags.BoolVar(&opts.version, "version", false, "show version and exit")
return flags, opts
}

Expand All @@ -95,6 +103,7 @@ type options struct {
junitFile string
noColor bool
noSummary *noSummaryValue
version bool
}

func setupLogging(opts *options) {
Expand Down

0 comments on commit 66227f6

Please sign in to comment.