// options package main import ( "flag" "fmt" // "gopkg.in/mgo.v2" "log" "os" "path" "path/filepath" "time" ) type Options struct { MongoSrc string MongoDst string DstDB string StartDate string Duration time.Duration Interval time.Duration LogFile string Influxdb string Hostname string Version bool Debug bool Bulk bool Batch int Exe string } func usage() { fmt.Println("Usage: lastlogin_consolidate -ms -md -l -d -I -bulk -v\n") os.Exit(0) } func init() { current, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { log.Fatal(err) } opts.LogFile = path.Join(current, opts.LogFile) flag.StringVar(&opts.MongoSrc, "ms", opts.MongoSrc, "Mongodb Source") flag.StringVar(&opts.MongoDst, "md", "", "Mongodb Destination") flag.StringVar(&opts.MongoDst, "dd", opts.DstDB, "Database Destination") flag.StringVar(&opts.Influxdb, "I", "", "Influxdb uri") flag.StringVar(&opts.Hostname, "H", "", "Hostname") flag.StringVar(&opts.LogFile, "l", opts.LogFile, "Logs filename") flag.StringVar(&opts.StartDate, "d", opts.StartDate, "Date") flag.DurationVar(&opts.Duration, "du", opts.Duration, "Duration") flag.DurationVar(&opts.Interval, "i", opts.Interval, "Duration") flag.BoolVar(&opts.Version, "v", false, "Version") flag.BoolVar(&opts.Debug, "debug", false, "Debug") flag.BoolVar(&opts.Bulk, "bulk", false, "Bulk") }