mirror of https://github.com/status-im/consul.git
Fix Keyring and keygen commands to build help string in constructor
This commit is contained in:
parent
85a834d008
commit
b1d5f99a58
|
@ -12,17 +12,19 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
type cmd struct {
|
type cmd struct {
|
||||||
UI cli.Ui
|
UI cli.Ui
|
||||||
flags *flag.FlagSet
|
flags *flag.FlagSet
|
||||||
|
usage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) initFlags() {
|
func (c *cmd) init() {
|
||||||
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
|
c.usage = flags.Usage(usage, c.flags, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Run(args []string) int {
|
func (c *cmd) Run(args []string) int {
|
||||||
|
@ -50,11 +52,11 @@ func (c *cmd) Synopsis() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Help() string {
|
func (c *cmd) Help() string {
|
||||||
s := `Usage: consul keygen
|
return c.usage
|
||||||
|
}
|
||||||
|
|
||||||
|
const usage = `Usage: consul keygen
|
||||||
|
|
||||||
Generates a new encryption key that can be used to configure the
|
Generates a new encryption key that can be used to configure the
|
||||||
agent to encrypt traffic. The output of this command is already
|
agent to encrypt traffic. The output of this command is already
|
||||||
in the proper format that the agent expects.`
|
in the proper format that the agent expects.`
|
||||||
|
|
||||||
return flags.Usage(s, c.flags, nil, nil)
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,7 +12,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ type cmd struct {
|
||||||
UI cli.Ui
|
UI cli.Ui
|
||||||
flags *flag.FlagSet
|
flags *flag.FlagSet
|
||||||
http *flags.HTTPFlags
|
http *flags.HTTPFlags
|
||||||
|
usage string
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
installKey string
|
installKey string
|
||||||
|
@ -29,7 +30,7 @@ type cmd struct {
|
||||||
relay int
|
relay int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) initFlags() {
|
func (c *cmd) init() {
|
||||||
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
c.flags = flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
c.flags.StringVar(&c.installKey, "install", "",
|
c.flags.StringVar(&c.installKey, "install", "",
|
||||||
"Install a new encryption key. This will broadcast the new key to "+
|
"Install a new encryption key. This will broadcast the new key to "+
|
||||||
|
@ -51,6 +52,7 @@ func (c *cmd) initFlags() {
|
||||||
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 {
|
||||||
|
@ -164,7 +166,10 @@ func (c *cmd) Synopsis() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cmd) Help() string {
|
func (c *cmd) Help() string {
|
||||||
s := `Usage: consul keyring [options]
|
return c.usage
|
||||||
|
}
|
||||||
|
|
||||||
|
const usage = `Usage: consul keyring [options]
|
||||||
|
|
||||||
Manages encryption keys used for gossip messages. Gossip encryption is
|
Manages encryption keys used for gossip messages. Gossip encryption is
|
||||||
optional. When enabled, this command may be used to examine active encryption
|
optional. When enabled, this command may be used to examine active encryption
|
||||||
|
@ -178,5 +183,3 @@ func (c *cmd) Help() string {
|
||||||
All variations of the keyring command return 0 if all nodes reply and there
|
All variations of the keyring command return 0 if all nodes reply and there
|
||||||
are no errors. If any node fails to reply or reports failure, the exit code
|
are no errors. If any node fails to reply or reports failure, the exit code
|
||||||
will be 1.`
|
will be 1.`
|
||||||
return flags.Usage(s, c.flags, c.http.ClientFlags(), c.http.ServerFlags())
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue