Permalink
Browse files

Improve usage (help) message

Change-Id: I9ef33f151dd90b1e55d10de07ef553d4ddf0dc43
  • Loading branch information...
1 parent 9003452 commit 011a0053747726c3b4d3be4e8740a45d8948b278 @dougm dougm committed Sep 5, 2012
Showing with 36 additions and 0 deletions.
  1. +36 −0 gonit/main.go
View
@@ -85,6 +85,42 @@ func parseFlags() {
flag.StringVar(&rpcUrl, "s", defaultRpcUrl, "RPC server URL")
flag.DurationVar(&polltime, "d", 0, "Run as a daemon with duration")
+ const named = "the named process or group"
+ const all = "all processes"
+
+ actions := []struct {
+ usage string
+ description string
+ what string
+ }{
+ {"start all", "Start", all},
+ {"start name", "Only start", named},
+ {"stop all", "Stop", all},
+ {"stop name", "Only stop", named},
+ {"restart all", "Restart", all},
+ {"restart name", "Only restart", named},
+ {"monitor all", "Enable monitoring for", all},
+ {"monitor name", "Only enable monitoring of", named},
+ {"unmonitor all", "Disable monitoring for", all},
+ {"unmonitor name", "Only disable monitoring of", named},
+ {"status all", "Print full status info for", all},
+ {"status name", "Only print short status info for", named},
+ {"summary", "Print short status information for", all},
+ }
+
+ flag.Usage = func() {
+ fmt.Println("Usage:", name, "[options] {arguments}")
+
+ fmt.Println("Options are as follows:")
+ flag.PrintDefaults()
+
+ fmt.Println("Optional action arguments are as follows:")
+ for _, action := range actions {
+ fmt.Printf(" %-20s - %s %s\n", action.usage,
+ action.description, action.what)
+ }
+ }
+
flag.Parse()
}

0 comments on commit 011a005

Please sign in to comment.