Fix join command to build help string in constructor

This commit is contained in:
Preetha Appan 2017-10-11 16:46:53 -05:00 committed by Frank Schröder
parent 0e1ee70a5e
commit b8dd539037
1 changed files with 8 additions and 6 deletions

View File

@ -10,7 +10,7 @@ import (
func New(ui cli.Ui) *cmd {
c := &cmd{UI: ui}
c.initFlags()
c.init()
return c
}
@ -18,16 +18,18 @@ type cmd struct {
UI cli.Ui
flags *flag.FlagSet
http *flags.HTTPFlags
usage string
wan bool
}
func (c *cmd) initFlags() {
func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.flags.BoolVar(&c.wan, "wan", false,
"Joins a server to another server in the WAN pool.")
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 {
@ -73,10 +75,10 @@ func (c *cmd) Synopsis() string {
}
func (c *cmd) Help() string {
s := `Usage: consul join [options] address ...
return c.usage
}
const usage = `Usage: consul join [options] address ...
Tells a running Consul agent (with "consul agent") to join the cluster
by specifying at least one existing member.`
return flags.Usage(s, c.flags, c.http.ClientFlags(), nil)
}