Skip to content

Commit e8e00d9

Browse files
Add -version flag, print version (#130)
1 parent 48a765a commit e8e00d9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmd/freno/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ import (
1616
// AppVersion has to be filled by ldflags:
1717
var AppVersion string
1818

19+
// GitCommit represents the git commit of Freno
20+
var GitCommit string
21+
1922
func main() {
2023
if AppVersion == "" {
2124
AppVersion = "local-build"
2225
}
26+
if GitCommit == "" {
27+
GitCommit = "unknown"
28+
}
2329

2430
configFile := flag.String("config", "", "config file name")
2531
http := flag.Bool("http", false, "spawn the HTTP API server")
@@ -34,6 +40,7 @@ func main() {
3440
forceLeadership := flag.Bool("force-leadership", false, "Make this node consider itself a leader no matter what consensus logic says")
3541

3642
quiet := flag.Bool("quiet", false, "quiet")
43+
version := flag.Bool("version", false, "print version")
3744
verbose := flag.Bool("verbose", false, "verbose")
3845
debug := flag.Bool("debug", false, "debug mode (very verbose)")
3946
stack := flag.Bool("stack", false, "add stack trace upon error")
@@ -46,6 +53,10 @@ func main() {
4653
printUsage()
4754
return
4855
}
56+
if *version {
57+
fmt.Printf("freno version %s, git commit %s\n", AppVersion, GitCommit)
58+
return
59+
}
4960

5061
log.SetLevel(log.ERROR)
5162
if *verbose {
@@ -61,7 +72,7 @@ func main() {
6172
// Override!!
6273
log.SetLevel(log.ERROR)
6374
}
64-
log.Infof("starting freno %s", AppVersion)
75+
log.Infof("starting freno %s, git commit %s", AppVersion, GitCommit)
6576

6677
loadConfiguration(*configFile)
6778

0 commit comments

Comments
 (0)