diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0f7b086..04a83b2 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,7 +16,7 @@ builds: ldflags: - '-s' - '-w' - - '-X github.com/nothub/gobonsai/buildinfo.Version={{ .Version }}' + - '-X main.Version={{ .Version }}' goos: - linux - darwin diff --git a/README.md b/README.md index 31ffa56..4295535 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,12 @@ Flags: -p, --print print first tree to stdout and exit immediately -s, --seed int seed random number generator (default random) -h, --help show help + -V, --version show version ``` --- -[gobonsai](https://github.com/nothub/gobonsai) is a `go` port of -[cbonsai](https://gitlab.com/jallbrit/cbonsai) (written in `C` and itself a port of -[bonsai.sh](https://gitlab.com/jallbrit/bonsai.sh) (written in `bash` and itself a port of +[gobonsai](https://github.com/nothub/gobonsai) is a `go` port of +[cbonsai](https://gitlab.com/jallbrit/cbonsai) (written in `C` and itself a port of +[bonsai.sh](https://gitlab.com/jallbrit/bonsai.sh) (written in `bash` and itself a port of [bonsai](https://avelican.github.io/bonsai/) (written in `javascript`))). diff --git a/buildinfo.go b/buildinfo.go index 946cea6..d79a432 100644 --- a/buildinfo.go +++ b/buildinfo.go @@ -1,4 +1,4 @@ package main // The Version variable will be populated at build-time. -var Version = "" +var Version = "unknown" diff --git a/options.go b/options.go index 76f909b..77d3af1 100644 --- a/options.go +++ b/options.go @@ -56,6 +56,7 @@ func options() opts { pflag.BoolVarP(&o.print, "print", "p", false, "print first tree to stdout and exit immediately") seed := pflag.Int64P("seed", "s", 0, "seed random number generator (default random)") help := pflag.BoolP("help", "h", false, "show help") + version := pflag.BoolP("version", "V", false, "show version") pflag.Parse() if *help { @@ -71,6 +72,11 @@ func options() opts { os.Exit(0) } + if *version { + fmt.Printf("Version: %s\n", Version) + os.Exit(0) + } + if o.screensaver { o.live = true o.infinite = true