Add VersionString func to print out full app version

This commit is contained in:
Dan Sosedoff 2022-12-06 11:27:47 -06:00
parent 3e1a93296e
commit 97e41fbfe5
No known key found for this signature in database
GPG Key ID: 26186197D282B164
2 changed files with 22 additions and 15 deletions

View File

@ -176,21 +176,7 @@ func initOptions() {
}
func printVersion() {
chunks := []string{fmt.Sprintf("Pgweb v%s", command.Version)}
if command.GitCommit != "" {
chunks = append(chunks, fmt.Sprintf("(git: %s)", command.GitCommit))
}
if command.GoVersion != "" {
chunks = append(chunks, fmt.Sprintf("(go: %s)", command.GoVersion))
}
if command.BuildTime != "" {
chunks = append(chunks, fmt.Sprintf("(build time: %s)", command.BuildTime))
}
fmt.Println(strings.Join(chunks, " "))
fmt.Println(command.VersionString())
}
func startServer() {

View File

@ -1,5 +1,10 @@
package command
import (
"fmt"
"strings"
)
const (
// Version is the current Pgweb application version
Version = "0.11.12"
@ -32,3 +37,19 @@ func init() {
Info.BuildTime = BuildTime
Info.GoVersion = GoVersion
}
func VersionString() string {
chunks := []string{fmt.Sprintf("Pgweb v%s", Version)}
if GitCommit != "" {
chunks = append(chunks, fmt.Sprintf("(git: %s)", GitCommit))
}
if GoVersion != "" {
chunks = append(chunks, fmt.Sprintf("(go: %s)", GoVersion))
}
if BuildTime != "" {
chunks = append(chunks, fmt.Sprintf("(build time: %s)", BuildTime))
}
return strings.Join(chunks, " ")
}