Fix exec and event commands to build help string in constructor
This commit is contained in:
parent
3bd4b738c0
commit
0cb1c92977
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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. `
|
||||
|
|
Loading…
Reference in New Issue