diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-04-06 12:56:04 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2020-04-08 15:45:01 +0300 |
commit | 1765378dd8bd921513e0dd73218d0f8c09b44f9d (patch) | |
tree | 0a02f70026c4c42c37fd35e6e644143fef45edcd | |
parent | 3016db2f28ed9d33dd09acf8a2f20922ed7d4016 (diff) |
praefect: List available subcommands on help
It's hard if not impossible to know which commands are supported by the
"praefect" executable. Now that we've migrated them to be contained in a
map of subcommands, we can easily generate a list of available commands
and print them as part of our usage.
-rw-r--r-- | cmd/praefect/main.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/praefect/main.go b/cmd/praefect/main.go index 9814d795b..dff299354 100644 --- a/cmd/praefect/main.go +++ b/cmd/praefect/main.go @@ -83,6 +83,17 @@ var ( const progname = "praefect" func main() { + flag.Usage = func() { + cmds := []string{} + for k, _ := range subcommands { + cmds = append(cmds, k) + } + + printfErr("Usage of %s:\n", progname) + flag.PrintDefaults() + printfErr(" subcommand (optional)\n") + printfErr("\tOne of %s\n", strings.Join(cmds, ", ")) + } flag.Parse() // If invoked with -version |