Use flag '-v'

This commit is contained in:
Siegfried Siegert 2020-09-05 07:49:43 +02:00
parent 12098aec70
commit 4a66fc4566

View File

@ -6,6 +6,7 @@ import (
"mqttListener/models"
"mqttListener/mqtt"
"flag"
"fmt"
"log"
@ -38,6 +39,7 @@ var BuildDate string
// Version holds contents of ./VERSION file, if exists, or the value passed via the -version option
var Version string
// PrintVersion prints version information
func PrintVersion() {
var versionString string = GitSummary
fmt.Println("\n--------------------------------------------------------")
@ -53,6 +55,13 @@ func PrintVersion() {
// ---------------------------------------------------------------------------
func main() {
versionFlagPtr := flag.Bool("v", false, "print version")
flag.Parse()
if *versionFlagPtr {
PrintVersion()
os.Exit(0)
}
PrintVersion()
c := make(chan os.Signal, 1)