From ec5745b22c58816290e586cb008807060ec9f6ab Mon Sep 17 00:00:00 2001 From: boseji Date: Tue, 20 Aug 2024 06:04:11 +0530 Subject: [PATCH] =?UTF-8?q?=E0=A4=AA=E0=A5=81=E0=A4=A8=E0=A4=B0=E0=A5=80?= =?UTF-8?q?=E0=A4=95=E0=A5=8D=E0=A4=B7=E0=A4=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 765f059..679a530 100644 --- a/main.go +++ b/main.go @@ -49,6 +49,7 @@ package main import ( "context" "flag" + "fmt" "log" "os" "os/signal" @@ -57,6 +58,10 @@ import ( "time" ) +const ( + version = "0.0.3" +) + func main() { var wg sync.WaitGroup var cfg cfg @@ -65,12 +70,26 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + fmt.Println("\n go-mli Boseji's Golang MQTT Logging command line") + fmt.Println("--------------------------------------------------") + fmt.Println(" Version: " + version) + fmt.Println() + defer fmt.Println() // Clearing the Last line + // Define Flags cfgFile := flag.String("config", "config.json", "JSON File containing the Configuration.") + ver := flag.Bool("v", false, "Version number of the program") flag.Parse() - log.Println("[main] Flag ", flag.Parsed()) + log.Println("[main] Flag Processed: ", flag.Parsed()) + + // Print version only + if *ver { + log.Println("[main] Program Version :" + version) + return + } + // Get the Config File configFile, err := filepath.Abs(*cfgFile) if err != nil {