Skip to content

Commit

Permalink
fix: cleaned up the flag, added the short form, and display os and ar…
Browse files Browse the repository at this point in the history
…ch with version
  • Loading branch information
Jeff Roche committed Jun 2, 2022
1 parent 230e384 commit 0ed882b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ before:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
#- go generate ./...
builds:
- env:
- CGO_ENABLED=0
Expand All @@ -17,7 +17,7 @@ builds:
- amd64
- arm64
ldflags:
- -X "github.com/jeff-roche/biome/main.Version={{.Env.VERSION}}"
- -X 'main.Version={{.Env.VERSION}} {{.Os}} {{.Arch}}'
archives:
- replacements:
darwin: Darwin
Expand Down
16 changes: 12 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ import (
"github.com/jeff-roche/biome/parser"
)

var Version string = "v0.X.Y - installed via go install"
var Version string

func main() {
var versionFlag bool
flag.BoolVar(&versionFlag, "version", false, "Display the current version of this utility")
flag.BoolVar(&versionFlag, "v", false, "Display the current version of this utility")

biomeName := flag.String("b", "", "[Required] The name of the biome to use")
versionFlag := flag.Bool("version", false, "Display the current version")

flag.Parse()

// If they want to print the version, just do that
if *versionFlag {
fmt.Println(Version)
if versionFlag {
if Version == "" {
fmt.Println("v0.X - installed via go install")
} else {
fmt.Println(Version)
}

return // We're done here
}

Expand Down

0 comments on commit 0ed882b

Please sign in to comment.