Skip to content

Commit

Permalink
Better version printing
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy committed Mar 23, 2024
1 parent 98c34c5 commit a49fada
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/bz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"path"
"path/filepath"
"regexp"
"runtime/debug"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -218,11 +219,18 @@ func (b *bz) info() error {
}

func (b *bz) version() error {
fmt.Printf(
`Version: %s
if version == "dev" {
info, ok := debug.ReadBuildInfo()
if !ok {
return errors.New("Could not determine version number")
}
fmt.Printf(`Version: %s\n`, info.Main.Version)
} else {
fmt.Printf(
`Version: %s
Commit: %s
Date %s`, version, commit, date)
fmt.Println()
Date %s\n`, version, commit, date)
}
return nil
}

Expand Down

0 comments on commit a49fada

Please sign in to comment.