// options package main import ( "flag" "fmt" "gopkg.in/mgo.v2" "log" "os" "path" "path/filepath" "time" ) type Options struct { MongoSrc string MongoDst string mdbSrc *mgo.Session mdbDst *mgo.Session ll *mgo.Collection lc *mgo.Collection StartDate string Duration time.Duration Interval time.Duration LogFile string Version bool Debug bool } func usage() { fmt.Println("Usage: lastlogin_consolidate -ms -md -l -d -dd -i -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.LogFile, "l", opts.LogFile, "Logs filename") flag.StringVar(&opts.StartDate, "d", opts.StartDate, "Date") flag.DurationVar(&opts.Duration, "dd", 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") }