diff --git a/command/catlistdc/catalog_list_datacenters.go b/command/catlistdc/catalog_list_datacenters.go index 86bf0adfb9..b1051f1d04 100644 --- a/command/catlistdc/catalog_list_datacenters.go +++ b/command/catlistdc/catalog_list_datacenters.go @@ -10,7 +10,7 @@ import ( func New(ui cli.Ui) *cmd { c := &cmd{UI: ui} - c.initFlags() + c.init() return c } @@ -18,13 +18,15 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags + usage string } -func (c *cmd) initFlags() { +func (c *cmd) init() { c.flags = flag.NewFlagSet("", flag.ContinueOnError) 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 { @@ -61,7 +63,10 @@ func (c *cmd) Synopsis() 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 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 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()) -}