mirror of https://github.com/status-im/consul.git
Fix up list datacenters to build help string in constructor
This commit is contained in:
parent
9d52f6ea92
commit
2ed2c63a26
|
@ -10,7 +10,7 @@ import (
|
||||||
|
|
||||||
func New(ui cli.Ui) *cmd {
|
func New(ui cli.Ui) *cmd {
|
||||||
c := &cmd{UI: ui}
|
c := &cmd{UI: ui}
|
||||||
c.initFlags()
|
c.init()
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,13 +18,15 @@ type cmd struct {
|
||||||
UI cli.Ui
|
UI cli.Ui
|
||||||
flags *flag.FlagSet
|
flags *flag.FlagSet
|
||||||
http *flags.HTTPFlags
|
http *flags.HTTPFlags
|
||||||
|
usage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) initFlags() {
|
func (c *cmd) init() {
|
||||||
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
c.http = &flags.HTTPFlags{}
|
c.http = &flags.HTTPFlags{}
|
||||||
flags.Merge(c.flags, c.http.ClientFlags())
|
flags.Merge(c.flags, c.http.ClientFlags())
|
||||||
flags.Merge(c.flags, c.http.ServerFlags())
|
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 {
|
func (c *cmd) Run(args []string) int {
|
||||||
|
@ -61,7 +63,10 @@ func (c *cmd) Synopsis() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Help() string {
|
func (c *cmd) Help() string {
|
||||||
s := `Usage: consul catalog datacenters [options]
|
return c.usage
|
||||||
|
}
|
||||||
|
|
||||||
|
const usage = `Usage: consul catalog datacenters [options]
|
||||||
|
|
||||||
Retrieves the list of all known datacenters. This datacenters are sorted in
|
Retrieves the list of all known datacenters. This datacenters are sorted in
|
||||||
ascending order based on the estimated median round trip time from the servers
|
ascending order based on the estimated median round trip time from the servers
|
||||||
|
@ -72,5 +77,3 @@ func (c *cmd) Help() string {
|
||||||
$ consul catalog datacenters
|
$ consul catalog datacenters
|
||||||
|
|
||||||
For a full list of options and examples, please see the Consul documentation.`
|
For a full list of options and examples, please see the Consul documentation.`
|
||||||
return flags.Usage(s, c.flags, c.http.ClientFlags(), c.http.ServerFlags())
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue