Skip to content

Commit

Permalink
encode: Improved command usage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenart committed Aug 18, 2018
1 parent f01a574 commit 9d45d92
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,34 @@ const (
encodingJSON = "json"
)

const encodeUsage = `Usage: vegeta encode [options] [<file>...]
Encodes vegeta attack results from one encoding to another.
The supported encodings are Gob (binary), CSV and JSON.
Each input file may have a different encoding which is detected
automatically.
Arguments:
<file> A file with vegeta attack results encoded with one of
the supported encodings (gob | json | csv) [default: stdin]
Options:
--to Output encoding (gob | json | csv) [default: json]
--output Output file [default: stdout]
Examples:
echo "GET http://:80" | vegeta attack -rate=1/s > results.gob
cat results.gob | vegeta encode | jq -c 'del(.body)' | vegeta encode -to gob
`

func encodeCmd() command {
encs := "[" + strings.Join([]string{encodingCSV, encodingGob, encodingJSON}, ", ") + "]"
fs := flag.NewFlagSet("vegeta encode", flag.ExitOnError)
to := fs.String("to", encodingJSON, "Output encoding "+encs)
output := fs.String("output", "stdout", "Output file")

fs.Usage = func() {
fmt.Println("Usage: vegeta encode [flags] [<file>...]")
fs.PrintDefaults()
fmt.Fprintln(os.Stderr, encodeUsage)
}

return command{fs, func(args []string) error {
Expand Down

0 comments on commit 9d45d92

Please sign in to comment.