Browse Source

command/keys: fail fast if no actionable args were passed

pull/336/head
Ryan Uber 10 years ago
parent
commit
0f611572cc
  1. 24
      command/keys.go

24
command/keys.go

@ -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…
Cancel
Save