Skip to content

Commit

Permalink
version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Mar 24, 2024
1 parent 2ea3632 commit 558798c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ builds:
ldflags:
- '-s'
- '-w'
- '-X github.com/nothub/gobonsai/buildinfo.Version={{ .Version }}'
- '-X main.Version={{ .Version }}'
goos:
- linux
- darwin
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`))).
2 changes: 1 addition & 1 deletion buildinfo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

// The Version variable will be populated at build-time.
var Version = ""
var Version = "unknown"
6 changes: 6 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 558798c

Please sign in to comment.