version number

This commit is contained in:
Michele Fadda 2015-07-16 15:18:29 +02:00
parent b3bec559d3
commit e8d6965e25

10
main.go
View file

@ -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 <date (yyyy-mm-dd:hh)> -r <date range (HHh)> -m <mongodb uri> -l <logfile>\n")
fmt.Println("Usage: imp_mongo -d <date (yyyy-mm-dd:hh)> -r <date range (HHh)> -m <mongodb uri> -l <logfile> -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 <YYYY-MM-DD:HH>")
flag.DurationVar(&opts.DateStop, "r", opts.DateStop, "Duration <HH>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())