llconsolidate/options.go

56 lines
1.4 KiB
Go
Raw Normal View History

2015-11-20 17:11:36 +01:00
// options
package main
import (
"flag"
"fmt"
// "gopkg.in/mgo.v2"
2015-11-20 17:11:36 +01:00
"log"
"os"
"path"
"path/filepath"
"time"
)
type Options struct {
2016-04-22 12:02:03 +02:00
MongoSrc string
MongoDst 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
2015-11-20 17:11:36 +01:00
}
func usage() {
2016-04-22 12:02:03 +02:00
fmt.Println("Usage: lastlogin_consolidate -ms <mongo source mongodb://IP:PORT> -md <mongo destination mongodb://IP:PORT> -l <logfile> -d <date> -I <influxdb uri> -bulk -v\n")
2015-11-20 17:11:36 +01:00
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")
2016-02-19 10:48:55 +01:00
flag.StringVar(&opts.Influxdb, "I", "", "Influxdb uri")
flag.StringVar(&opts.Hostname, "H", "", "Hostname")
2015-11-20 17:11:36 +01:00
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")
2016-04-15 15:28:52 +02:00
flag.BoolVar(&opts.Bulk, "bulk", false, "Bulk")
2015-11-20 17:11:36 +01:00
}