etcdctl: minor cleanup

This commit is contained in:
Xiang Li
2015-06-02 19:44:26 -07:00
parent 079e7c10a0
commit f0edf06b6d
8 changed files with 10 additions and 12 deletions

View File

@@ -41,12 +41,12 @@ func NewSetCommand() cli.Command {
// setCommandFunc executes the "set" command.
func setCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error) {
if len(c.Args()) == 0 {
return nil, errors.New("Key required")
return nil, errors.New("key required")
}
key := c.Args()[0]
value, err := argOrStdin(c.Args(), os.Stdin, 1)
if err != nil {
return nil, errors.New("Value required")
return nil, errors.New("value required")
}
ttl := c.Int("ttl")
@@ -55,7 +55,6 @@ func setCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error)
if prevValue == "" && prevIndex == 0 {
return client.Set(key, value, uint64(ttl))
} else {
return client.CompareAndSwap(key, value, uint64(ttl), prevValue, uint64(prevIndex))
}
return client.CompareAndSwap(key, value, uint64(ttl), prevValue, uint64(prevIndex))
}