From e8d6965e25eddc142846f9eaa7f55a6589514e47 Mon Sep 17 00:00:00 2001 From: Michele Fadda Date: Thu, 16 Jul 2015 15:18:29 +0200 Subject: [PATCH] version number --- main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 24e3615..ac53af3 100644 --- a/main.go +++ b/main.go @@ -22,9 +22,11 @@ type Options struct { DateStart string TimeStart time.Time DateStop time.Duration + Version bool } const ( + _VERSION = "v1.0.2" _dashboard = "/dashboard?suser=admin&spass=FreakKitchen&type=counters&view=hour&date=" _domain = ".mail.tiscali.sys" _port = "8082" @@ -53,7 +55,7 @@ func connectMongo() { } func usage() { - fmt.Println("Usage: imp_mongo -d -r -m -l \n") + fmt.Println("Usage: imp_mongo -d -r -m -l -v\n") os.Exit(0) } @@ -69,6 +71,7 @@ func init() { flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename") flag.StringVar(&opts.DateStart, "d", opts.DateStart, "From Date ") flag.DurationVar(&opts.DateStop, "r", opts.DateStop, "Duration h") + flag.BoolVar(&opts.Version, "v", false, "Version") } func parseDate(date string) string { @@ -93,6 +96,11 @@ func main() { flag.Usage = usage flag.Parse() + if opts.Version { + fmt.Println(os.Args[0], _VERSION) + os.Exit(0) + } + fs, err := os.OpenFile(opts.LogFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666) if err != nil { fmt.Println("Log file error: ", err.Error())