2013-08-13 13:47:01 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"flag"
|
|
|
|
|
"log"
|
2013-08-14 18:24:20 +02:00
|
|
|
"runtime"
|
2013-08-13 13:47:01 +02:00
|
|
|
)
|
|
|
|
|
|
2013-09-11 00:10:35 +01:00
|
|
|
// command is a closure function which each command constructor
|
|
|
|
|
// builds and returns
|
|
|
|
|
type command func() error
|
|
|
|
|
|
2013-08-13 13:47:01 +02:00
|
|
|
func main() {
|
2013-09-11 00:10:35 +01:00
|
|
|
commands := map[string]func([]string) command{
|
|
|
|
|
"attack": attackCmd,
|
|
|
|
|
"report": reportCmd,
|
|
|
|
|
}
|
2013-09-10 21:47:37 +01:00
|
|
|
// Global flags
|
|
|
|
|
cpus := flag.Int("cpus", runtime.NumCPU(), "Number of CPUs to use")
|
2013-08-13 13:47:01 +02:00
|
|
|
flag.Parse()
|
2013-09-10 21:47:37 +01:00
|
|
|
args := flag.Args()
|
2013-09-07 22:59:12 +01:00
|
|
|
|
2013-09-11 00:10:35 +01:00
|
|
|
runtime.GOMAXPROCS(*cpus)
|
2013-09-07 22:59:12 +01:00
|
|
|
|
2013-09-11 00:10:35 +01:00
|
|
|
if cmd, ok := commands[args[0]]; !ok {
|
|
|
|
|
log.Fatalf("Unknown command: %s", args[0])
|
|
|
|
|
} else if err := cmd(args[1:])(); err != nil {
|
|
|
|
|
log.Fatal(err)
|
2013-08-13 13:47:01 +02:00
|
|
|
}
|
|
|
|
|
}
|