forked from hofstadter-io/hof
/
version.go
66 lines (46 loc) · 999 Bytes
/
version.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package cmd
import (
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
"github.com/hofstadter-io/hof/cmd/hof/verinfo"
)
const versionMessage = `
Version: v%s
Commit: %s
BuildDate: %s
GoVersion: %s
OS / Arch: %s %s
Author: Hofstadter, Inc
Homepage: https://hofstadter.io
GitHub: https://github.com/hofstadter-io/hof
`
var VersionLong = `Print the build version for hof`
var VersionCmd = &cobra.Command{
Use: "version",
Aliases: []string{
"ver",
},
Short: "print the version",
Long: VersionLong,
Run: func(cmd *cobra.Command, args []string) {
s, e := os.UserConfigDir()
fmt.Printf("hof ConfigDir %q %v\n", filepath.Join(s, "hof"), e)
fmt.Printf(
versionMessage,
verinfo.Version,
verinfo.Commit,
verinfo.BuildDate,
verinfo.GoVersion,
verinfo.BuildOS,
verinfo.BuildArch,
)
},
}
func init() {
help := VersionCmd.HelpFunc()
usage := VersionCmd.UsageFunc()
VersionCmd.SetHelpFunc(help)
VersionCmd.SetUsageFunc(usage)
}