Fix up catalog list services to build help string in constructor
This commit is contained in:
parent
8761232b2a
commit
3bd4b738c0
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue