Files
old-vegeta/main.go

31 lines
581 B
Go
Raw Normal View History

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
)
// 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() {
commands := map[string]func([]string) command{
"attack": attackCmd,
"report": reportCmd,
}
// Global flags
cpus := flag.Int("cpus", runtime.NumCPU(), "Number of CPUs to use")
2013-08-13 13:47:01 +02:00
flag.Parse()
args := flag.Args()
2013-09-07 22:59:12 +01:00
runtime.GOMAXPROCS(*cpus)
2013-09-07 22:59:12 +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
}
}