11package main
22
33import (
4- "flag"
54 "fmt"
65 "os"
76 "os/signal"
@@ -11,6 +10,8 @@ import (
1110 "syscall"
1211 "time"
1312
13+ "gopkg.in/alecthomas/kingpin.v2"
14+
1415 "github.com/dustin/go-humanize"
1516 "github.com/goadapp/goad"
1617 "github.com/goadapp/goad/helpers"
@@ -20,6 +21,7 @@ import (
2021)
2122
2223var (
24+ app = kingpin .New ("goad" , "A command-line chat application." )
2325 url string
2426 concurrency uint
2527 requests uint
@@ -34,30 +36,24 @@ var (
3436const coldef = termbox .ColorDefault
3537const nano = 1000000000
3638
37- func main () {
38- var printVersion bool
39-
40- flag .StringVar (& url , "u" , "" , "URL to load test (required)" )
41- flag .StringVar (& method , "m" , "GET" , "HTTP method" )
42- flag .StringVar (& body , "b" , "" , "HTTP request body" )
43- flag .UintVar (& concurrency , "c" , 10 , "number of concurrent requests" )
44- flag .UintVar (& requests , "n" , 1000 , "number of total requests to make" )
45- flag .UintVar (& timeout , "t" , 15 , "request timeout in seconds" )
46- flag .StringVar (& regions , "r" , "us-east-1,eu-west-1,ap-northeast-1" , "AWS regions to run in (comma separated, no spaces)" )
47- flag .StringVar (& awsProfile , "p" , "" , "AWS named profile to use" )
48- flag .Var (& headers , "H" , "List of headers" )
49- flag .BoolVar (& printVersion , "version" , false , "print the current Goad version" )
50- flag .Parse ()
51-
52- if printVersion {
53- fmt .Println (version .Version )
54- os .Exit (0 )
55- }
39+ func init () {
40+ app .HelpFlag .Short ('h' )
5641
57- if url == "" {
58- flag .Usage ()
59- os .Exit (0 )
60- }
42+ url = * app .Flag ("url" , "URL to load test" ).Short ('u' ).Required ().String ()
43+ method = * app .Flag ("method" , "HTTP method" ).Short ('m' ).Default ("GET" ).String ()
44+ body = * app .Flag ("body" , "HTTP request body" ).Short ('b' ).String ()
45+ concurrency = * app .Flag ("concurrency" , "Number of concurrent requests" ).Short ('c' ).Default ("10" ).Uint ()
46+ requests = * app .Flag ("requests" , "Total number of requests to make" ).Short ('n' ).Default ("10" ).Uint ()
47+ timeout = * app .Flag ("timeout" , "Request timeout in seconds" ).Short ('t' ).Default ("15" ).Uint ()
48+ regions = * app .Flag ("regions" , "AWS regions to run in (comma separated, no spaces)" ).Short ('r' ).Default ("us-east-1,eu-west-1,ap-northeast-1" ).String ()
49+ awsProfile = * app .Flag ("aws-profile" , "AWS named profile to use" ).Short ('p' ).String ()
50+ app .Flag ("headers" , "List of headers" ).Short ('H' ).SetValue (& headers )
51+
52+ app .Version (version .Version )
53+ }
54+
55+ func main () {
56+ kingpin .MustParse (app .Parse (os .Args [1 :]))
6157
6258 test , testerr := goad .NewTest (& goad.TestConfig {
6359 URL : url ,
0 commit comments