<commit_before>package cli

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"os/signal"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"syscall"
	"time"

	"gopkg.in/alecthomas/kingpin.v2"
	ini "gopkg.in/ini.v1"

	"github.com/dustin/go-humanize"
	"github.com/goadapp/goad/goad"
	"github.com/goadapp/goad/queue"
	"github.com/goadapp/goad/version"
	"github.com/nsf/termbox-go"
)

const (
	coldef         = termbox.ColorDefault
	nano           = 1000000000
	general        = "general"
	urlKey         = "url"
	methodKey      = "method"
	bodyKey        = "body"
	concurrencyKey = "concurrency"
	requestsKey    = "requests"
	timelimitKey   = "timelimit"
	timeoutKey     = "timeout"
	jsonOutputKey  = "json-output"
	headerKey      = "header"
	regionKey      = "region"
	writeIniKey    = "create-ini-template"
	runDockerKey   = "run-docker"
)

var (
	iniFile         = "goad.ini"
	app             = kingpin.New("goad", "An AWS Lambda powered load testing tool")
	urlArg          = app.Arg(urlKey, "[http[s]://]hostname[:port]/path optional if defined in goad.ini")
	url             = urlArg.String()
	requestsFlag    = app.Flag(requestsKey, "Number of requests to perform. Set to 0 in combination with a specified timelimit allows for unlimited requests for the specified time.").Short('n').Default("1000")
	requests        = requestsFlag.Int()
	concurrencyFlag = app.Flag(concurrencyKey, "Number of multiple requests to make at a time").Short('c').Default("10")
	concurrency     = concurrencyFlag.Int()
	timelimitFlag   = app.Flag(timelimitKey, "Seconds to max. to spend on benchmarking").Short('t').Default("3600")
	timelimit       = timelimitFlag.Int()
	timeoutFlag     = app.Flag(timeoutKey, "Seconds to max. wait for each response").Short('s').Default("15")
	timeout         = timeoutFlag.Int()
	headersFlag     = app.Flag(headerKey, "Add Arbitrary header line, eg. 'Accept-Encoding: gzip' (repeatable)").Short('H')
	headers         = headersFlag.Strings()
	regionsFlag     = app.Flag(regionKey, "AWS regions to run in. Repeat flag to run in more then one region. (repeatable)")
	regions         = regionsFlag.Strings()
	outputFileFlag  = app.Flag(jsonOutputKey, "Optional path to file for JSON result storage")
	outputFile      = outputFileFlag.String()
	methodFlag      = app.Flag(methodKey, "HTTP method").Short('m').Default("GET")
	method          = methodFlag.String()
	bodyFlag        = app.Flag(bodyKey, "HTTP request body")
	body            = bodyFlag.String()
	writeIniFlag    = app.Flag(writeIniKey, "create sample configuration file \""+iniFile+"\" in current working directory")
	writeIni        = writeIniFlag.Bool()
	runDockerFlag   = app.Flag(runDockerKey, "execute in docker container instead of aws lambda")
	runDocker       = runDockerFlag.Bool()
)

// Run the goad cli
func Run() {
	app.HelpFlag.Short('h')
	app.Version(version.String())
	app.VersionFlag.Short('V')

	config := aggregateConfiguration()
	test := createGoadTest(config)

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	if config.Output != "" {
		defer saveJSONSummary(*outputFile, &finalResult)
	}

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}<commit_msg>Reorder parameters printed on the cli help<commit_after>package cli

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"math"
	"os"
	"os/signal"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"syscall"
	"time"

	"gopkg.in/alecthomas/kingpin.v2"
	ini "gopkg.in/ini.v1"

	"github.com/dustin/go-humanize"
	"github.com/goadapp/goad/goad"
	"github.com/goadapp/goad/queue"
	"github.com/goadapp/goad/version"
	"github.com/nsf/termbox-go"
)

const (
	coldef         = termbox.ColorDefault
	nano           = 1000000000
	general        = "general"
	urlKey         = "url"
	methodKey      = "method"
	bodyKey        = "body"
	concurrencyKey = "concurrency"
	requestsKey    = "requests"
	timelimitKey   = "timelimit"
	timeoutKey     = "timeout"
	jsonOutputKey  = "json-output"
	headerKey      = "header"
	regionKey      = "region"
	writeIniKey    = "create-ini-template"
	runDockerKey   = "run-docker"
)

var (
	iniFile         = "goad.ini"
	app             = kingpin.New("goad", "An AWS Lambda powered load testing tool")
	urlArg          = app.Arg(urlKey, "[http[s]://]hostname[:port]/path optional if defined in goad.ini")
	url             = urlArg.String()
	requestsFlag    = app.Flag(requestsKey, "Number of requests to perform. Set to 0 in combination with a specified timelimit allows for unlimited requests for the specified time.").Short('n').Default("1000")
	requests        = requestsFlag.Int()
	concurrencyFlag = app.Flag(concurrencyKey, "Number of multiple requests to make at a time").Short('c').Default("10")
	concurrency     = concurrencyFlag.Int()
	timelimitFlag   = app.Flag(timelimitKey, "Seconds to max. to spend on benchmarking").Short('t').Default("3600")
	timelimit       = timelimitFlag.Int()
	timeoutFlag     = app.Flag(timeoutKey, "Seconds to max. wait for each response").Short('s').Default("15")
	timeout         = timeoutFlag.Int()
	headersFlag     = app.Flag(headerKey, "Add Arbitrary header line, eg. 'Accept-Encoding: gzip' (repeatable)").Short('H')
	headers         = headersFlag.Strings()
	methodFlag      = app.Flag(methodKey, "HTTP method").Short('m').Default("GET")
	method          = methodFlag.String()
	bodyFlag        = app.Flag(bodyKey, "HTTP request body\n\n")
	body            = bodyFlag.String()
	outputFileFlag  = app.Flag(jsonOutputKey, "Optional path to file for JSON result storage")
	outputFile      = outputFileFlag.String()
	regionsFlag     = app.Flag(regionKey, "AWS regions to run in. Repeat flag to run in more then one region. (repeatable)")
	regions         = regionsFlag.Strings()
	runDockerFlag   = app.Flag(runDockerKey, "execute in docker container instead of aws lambda")
	runDocker       = runDockerFlag.Bool()
	writeIniFlag    = app.Flag(writeIniKey, "create sample configuration file \""+iniFile+"\" in current working directory")
	writeIni        = writeIniFlag.Bool()
)

// Run the goad cli
func Run() {
	app.HelpFlag.Short('h')
	app.Version(version.String())
	app.VersionFlag.Short('V')

	config := aggregateConfiguration()
	test := createGoadTest(config)

	var finalResult queue.RegionsAggData
	defer printSummary(&finalResult)

	if config.Output != "" {
		defer saveJSONSummary(*outputFile, &finalResult)
	}

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) // but interrupts from kbd are blocked by termbox

	start(test, &finalResult, sigChan)
}
{'fraction_non_alphanumeric': 0.12939943088213268, 'fraction_numerical': 0.007787928710498727, 'mean_word_length': 3.5336048879837065, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5025421', 'n_tokens_mistral': 2313, 'n_tokens_neox': 2223, 'n_words': 528}