From 3bd4b738c0a5e334e5eead839ba8c67ce8aa92e4 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 11 Oct 2017 16:15:53 -0500 Subject: [PATCH] Fix up catalog list services to build help string in constructor --- command/catlistsvc/catalog_list_services.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/command/catlistsvc/catalog_list_services.go b/command/catlistsvc/catalog_list_services.go index 6be982530..b61a74272 100644 --- a/command/catlistsvc/catalog_list_services.go +++ b/command/catlistsvc/catalog_list_services.go @@ -23,6 +23,7 @@ type cmd struct { UI cli.Ui flags *flag.FlagSet http *flags.HTTPFlags + usage string // flags node string @@ -45,10 +46,10 @@ 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 { - c.initFlags() if err := c.flags.Parse(args); err != nil { return 1 } @@ -129,7 +130,10 @@ func (c *cmd) Synopsis() string { } func (c *cmd) Help() string { - s := `Usage: consul catalog services [options] + return c.usage +} + +const usage = `Usage: consul catalog services [options] Retrieves the list services registered in a given datacenter. By default, the datacenter of the local agent is queried. @@ -151,5 +155,3 @@ func (c *cmd) Help() string { $ consul catalog services -node-meta="foo=bar" 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()) -}