/
versioncmd.go
47 lines (40 loc) · 1.06 KB
/
versioncmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"runtime"
"github.com/urfave/cli/v2"
)
const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
)
var (
clientIdentifier = "chainkv"
GitCommit string
GitDate string
)
var versionCommand = &cli.Command{
Action: printVersion,
Name: "version",
Aliases: []string{"v"},
Usage: "Print version numbers",
ArgsUsage: " ",
Description: `
The output of this command is supposed to be machine-readable.
`,
}
func printVersion(ctx *cli.Context) error {
fmt.Println(clientIdentifier)
fmt.Println("Version:", fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch))
if GitCommit != "" {
fmt.Println("Git Commit:", GitCommit)
}
if GitDate != "" {
fmt.Println("Git Commit Date:", GitDate)
}
fmt.Println("Architecture:", runtime.GOARCH)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("Operating System:", runtime.GOOS)
return nil
}