Skip to content

Commit

Permalink
Print version with -version flag (#138)
Browse files Browse the repository at this point in the history
Co-authored-by: Mat Ryer <matryer@users.noreply.github.com>
  • Loading branch information
breml and matryer committed Sep 18, 2020
1 parent be64288 commit 2ea3371
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// version is the command version, injected at build time.
var version string
var version string = "dev"

type userFlags struct {
outFile string
Expand All @@ -32,6 +32,7 @@ func main() {
flag.StringVar(&flags.formatter, "fmt", "", "go pretty-printer: gofmt, goimports or noop (default gofmt)")
flag.BoolVar(&flags.stubImpl, "stub", false,
"return zero values when no mock implementation is provided, do not panic")
printVersion := flag.Bool("version", false, "show the version for moq")
flag.BoolVar(&flags.skipEnsure, "skip-ensure", false,
"suppress mock implementation check, avoid import cycle if mocks generated outside of the tested package")

Expand All @@ -45,6 +46,11 @@ func main() {
flag.Parse()
flags.args = flag.Args()

if *printVersion {
fmt.Printf("moq version %s\n", version)
os.Exit(0)
}

if err := run(flags); err != nil {
fmt.Fprintln(os.Stderr, err)
flag.Usage()
Expand Down

0 comments on commit 2ea3371

Please sign in to comment.