Skip to content

Commit 558798c

Browse files
committed
version flag
1 parent 2ea3632 commit 558798c

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ builds:
1616
ldflags:
1717
- '-s'
1818
- '-w'
19-
- '-X github.com/nothub/gobonsai/buildinfo.Version={{ .Version }}'
19+
- '-X main.Version={{ .Version }}'
2020
goos:
2121
- linux
2222
- darwin

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ Flags:
3939
-p, --print print first tree to stdout and exit immediately
4040
-s, --seed int seed random number generator (default random)
4141
-h, --help show help
42+
-V, --version show version
4243
```
4344

4445
---
4546

46-
[gobonsai](https://github.com/nothub/gobonsai) is a `go` port of
47-
[cbonsai](https://gitlab.com/jallbrit/cbonsai) (written in `C` and itself a port of
48-
[bonsai.sh](https://gitlab.com/jallbrit/bonsai.sh) (written in `bash` and itself a port of
47+
[gobonsai](https://github.com/nothub/gobonsai) is a `go` port of
48+
[cbonsai](https://gitlab.com/jallbrit/cbonsai) (written in `C` and itself a port of
49+
[bonsai.sh](https://gitlab.com/jallbrit/bonsai.sh) (written in `bash` and itself a port of
4950
[bonsai](https://avelican.github.io/bonsai/) (written in `javascript`))).

buildinfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package main
22

33
// The Version variable will be populated at build-time.
4-
var Version = ""
4+
var Version = "unknown"

options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func options() opts {
5656
pflag.BoolVarP(&o.print, "print", "p", false, "print first tree to stdout and exit immediately")
5757
seed := pflag.Int64P("seed", "s", 0, "seed random number generator (default random)")
5858
help := pflag.BoolP("help", "h", false, "show help")
59+
version := pflag.BoolP("version", "V", false, "show version")
5960
pflag.Parse()
6061

6162
if *help {
@@ -71,6 +72,11 @@ func options() opts {
7172
os.Exit(0)
7273
}
7374

75+
if *version {
76+
fmt.Printf("Version: %s\n", Version)
77+
os.Exit(0)
78+
}
79+
7480
if o.screensaver {
7581
o.live = true
7682
o.infinite = true

0 commit comments

Comments
 (0)