add custom version string

Signed-off-by: Nathan13888 <29968201+Nathan13888@users.noreply.github.com>
This commit is contained in:
Nathan Chung 2023-06-25 00:51:58 -04:00
parent f62168a081
commit c225b0d04f
Signed by: n4chung
SSH Key Fingerprint: SHA256:/+NqYA5MfQIjjfwa4z16mw3Y+lxgY/Ml8wCeGnh6qBU
2 changed files with 13 additions and 1 deletions

View File

@ -1,6 +1,11 @@
package config
import "runtime"
import (
"fmt"
"runtime"
"github.com/urfave/cli/v2"
)
var (
BuildVersion = "development"
@ -11,3 +16,8 @@ var (
GOOS = runtime.GOOS
GOARCH = runtime.GOARCH
)
func PrintVersion(cCtx *cli.Context) {
fmt.Printf("version=%s buildTime=%s buildUser=%s buildGOOS=%s buildARCH=%s\n",
cCtx.App.Version, BuildTime, BuildUser, BuildGOOS, BuildARCH)
}

View File

@ -137,6 +137,8 @@ func main() {
},
}
cli.VersionPrinter = config.PrintVersion
if err := app.Run(os.Args); err != nil {
log.Fatal().Err(err).Msg("An error occurred.")
}