diff --git a/command/event/event.go b/command/event/event.go index b368b4d218..e4efadbdfc 100644 --- a/command/event/event.go +++ b/command/event/event.go @@ -24,6 +24,7 @@ type cmd struct { node string service string tag string + usage string } func (c *cmd) initFlags() { @@ -39,6 +40,7 @@ func (c *cmd) initFlags() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) + c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), nil) } func (c *cmd) Run(args []string) int { @@ -131,11 +133,11 @@ func (c *cmd) Synopsis() string { } func (c *cmd) Help() string { - s := `Usage: consul event [options] [payload] + return c.usage +} + +const usage = `Usage: consul event [options] [payload] Dispatches a custom user event across a datacenter. An event must provide a name, but a payload is optional. Events support filtering using regular expressions on node name, service, and tag definitions.` - - return flags.Usage(s, c.flags, c.http.ClientFlags(), nil) -} diff --git a/command/exec/exec.go b/command/exec/exec.go index dd54a2a1f5..5b5315f9cd 100644 --- a/command/exec/exec.go +++ b/command/exec/exec.go @@ -29,6 +29,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags + usage string shutdownCh <-chan struct{} conf rExecConf @@ -59,6 +60,7 @@ func (c *cmd) initFlags() { c.http = &flags.HTTPFlags{} flags.Merge(c.flags, c.http.ClientFlags()) flags.Merge(c.flags, c.http.ServerFlags()) + c.usage = flags.Usage(usage, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) } func (c *cmd) Run(args []string) int { @@ -185,13 +187,7 @@ func (c *cmd) Synopsis() string { } func (c *cmd) Help() string { - s := `Usage: consul exec [options] [-|command...] - - Evaluates a command on remote Consul nodes. The nodes responding can - be filtered using regular expressions on node name, service, and tag - definitions. If a command is '-', stdin will be read until EOF - and used as a script input. ` - return flags.Usage(s, c.flags, c.http.ClientFlags(), c.http.ServerFlags()) + return c.usage } // waitForJob is used to poll for results and wait until the job is terminated @@ -689,3 +685,10 @@ func (u *TargetedUI) prefixLines(arrow bool, message string) string { return strings.TrimRightFunc(result.String(), unicode.IsSpace) } + +const usage = `Usage: consul exec [options] [-|command...] + + Evaluates a command on remote Consul nodes. The nodes responding can + be filtered using regular expressions on node name, service, and tag + definitions. If a command is '-', stdin will be read until EOF + and used as a script input. `