Skip to content

Commit

Permalink
vegeta: Exclude deprecated cmds from help message
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenart committed Aug 18, 2018
1 parent ba2df25 commit 08190d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
6 changes: 2 additions & 4 deletions dump.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package main

import (
"flag"
"fmt"
)

func dumpCmd() command {
fs := flag.NewFlagSet("vegeta dump", flag.ExitOnError)
return command{fs, func([]string) error {
return fmt.Errorf("vegeta dump has been deprecated and succeeded by the vegeta encode command.")
return command{fn: func([]string) error {
return fmt.Errorf("vegeta dump has been deprecated and succeeded by the vegeta encode command")
}}
}
17 changes: 14 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"runtime"
"runtime/pprof"
"sort"
"strings"
)

Expand All @@ -28,10 +29,20 @@ func main() {
fmt.Println("Usage: vegeta [global flags] <command> [command flags]")
fmt.Printf("\nglobal flags:\n")
fs.PrintDefaults()
for name, cmd := range commands {
fmt.Printf("\n%s command:\n", name)
cmd.fs.PrintDefaults()

names := make([]string, 0, len(commands))
for name := range commands {
names = append(names, name)
}

sort.Strings(names)
for _, name := range names {
if cmd := commands[name]; cmd.fs != nil {
fmt.Printf("\n%s command:\n", name)
cmd.fs.PrintDefaults()
}
}

fmt.Println(examples)
}

Expand Down

0 comments on commit 08190d6

Please sign in to comment.