-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd_version.go
More file actions
37 lines (33 loc) · 775 Bytes
/
Copy pathcmd_version.go
File metadata and controls
37 lines (33 loc) · 775 Bytes
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
package main
import (
"fmt"
"io"
"os"
"text/tabwriter"
)
const VERSION = "0.2.4"
const GIT_DEF = "@"
var (
BUILD_TIME = "nil"
GIT_COMMIT = GIT_DEF
)
var versionHelp = &helpNode{
cmd: "version",
synopsis: "Print version information.",
usage: func(w io.Writer) {
cmdTitle(w, false, "version")
cmdUsage(w, "Output the version information.\n")
},
}
func versionHandler(args []string, data interface{}) (int, error) {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.TabIndent)
fmt.Fprintln(w, "Version\t:", cWrap(cGREEN, VERSION))
if BUILD_TIME != "nil" {
fmt.Fprintln(w, "Build time\t:", cWrap(cGREEN, BUILD_TIME))
}
if GIT_COMMIT != GIT_DEF {
fmt.Fprintln(w, "Git Commit\t:", cWrap(cGREEN, GIT_COMMIT))
}
w.Flush()
return 0, nil
}