commands: cleanup init

This commit is contained in:
Frank Schroeder 2017-10-18 02:38:26 +02:00
parent 282b88466b
commit 983e4aa0eb
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
3 changed files with 8 additions and 9 deletions

View File

@ -32,9 +32,6 @@ func New(ui cli.Ui) *cmd {
func (c *cmd) init() { func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.flags.BoolVar(&c.enable, "enable", false, c.flags.BoolVar(&c.enable, "enable", false,
"Enable maintenance mode.") "Enable maintenance mode.")
c.flags.BoolVar(&c.disable, "disable", false, c.flags.BoolVar(&c.disable, "disable", false,
@ -44,6 +41,8 @@ func (c *cmd) init() {
c.flags.StringVar(&c.serviceID, "service", "", c.flags.StringVar(&c.serviceID, "service", "",
"Control maintenance mode for a specific service ID.") "Control maintenance mode for a specific service ID.")
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.help = flags.Usage(help, c.flags) c.help = flags.Usage(help, c.flags)
} }

View File

@ -22,6 +22,7 @@ type cmd struct {
help string help string
flags *flag.FlagSet flags *flag.FlagSet
http *flags.HTTPFlags http *flags.HTTPFlags
// flags // flags
detailed bool detailed bool
wan bool wan bool
@ -37,9 +38,6 @@ func New(ui cli.Ui) *cmd {
func (c *cmd) init() { func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.flags.BoolVar(&c.detailed, "detailed", false, c.flags.BoolVar(&c.detailed, "detailed", false,
"Provides detailed information about nodes.") "Provides detailed information about nodes.")
c.flags.BoolVar(&c.wan, "wan", false, c.flags.BoolVar(&c.wan, "wan", false,
@ -51,6 +49,9 @@ func (c *cmd) init() {
c.flags.StringVar(&c.segment, "segment", consulapi.AllSegments, c.flags.StringVar(&c.segment, "segment", consulapi.AllSegments,
"(Enterprise-only) If provided, output is filtered to only nodes in"+ "(Enterprise-only) If provided, output is filtered to only nodes in"+
"the given segment.") "the given segment.")
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.help = flags.Usage(help, c.flags) c.help = flags.Usage(help, c.flags)
} }

View File

@ -34,12 +34,11 @@ func New(ui cli.Ui, shutdownCh <-chan struct{}) *cmd {
func (c *cmd) init() { func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.flags.StringVar(&c.logLevel, "log-level", "INFO", c.flags.StringVar(&c.logLevel, "log-level", "INFO",
"Log level of the agent.") "Log level of the agent.")
c.http = &flags.HTTPFlags{}
flags.Merge(c.flags, c.http.ClientFlags())
c.help = flags.Usage(help, c.flags) c.help = flags.Usage(help, c.flags)
} }