mirror of https://github.com/status-im/consul.git
command/keys: fail fast if no actionable args were passed
This commit is contained in:
parent
e4251a3372
commit
0f611572cc
|
@ -33,13 +33,6 @@ func (c *KeysCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
client, err := RPCClient(*rpcAddr)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))
|
||||
return 1
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// Only accept a single argument
|
||||
found := listKeys
|
||||
for _, arg := range []string{installKey, useKey, removeKey} {
|
||||
|
@ -50,6 +43,19 @@ func (c *KeysCommand) Run(args []string) int {
|
|||
found = found || len(arg) > 0
|
||||
}
|
||||
|
||||
// Fail fast if no actionable args were passed
|
||||
if !found {
|
||||
c.Ui.Error(c.Help())
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := RPCClient(*rpcAddr)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))
|
||||
return 1
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
if listKeys {
|
||||
var keys map[string]int
|
||||
var numNodes int
|
||||
|
@ -96,8 +102,8 @@ func (c *KeysCommand) Run(args []string) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
c.Ui.Output(c.Help())
|
||||
return 1
|
||||
// Should never make it here
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *KeysCommand) Help() string {
|
||||
|
|
Loading…
Reference in New Issue