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

@ -19,7 +19,7 @@ import (
"fmt"
"os"
"github.com/coreos/go-etcd/etcd"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-etcd/etcd"
)
// printKey writes the etcd response to STDOUT in the given format.

View File

@ -55,7 +55,7 @@ func printGet(resp *etcd.Response, format string) {
// getCommandFunc executes the "get" command.
func getCommandFunc(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]
sorted := c.Bool("sort")

View File

@ -39,12 +39,12 @@ func NewMakeCommand() cli.Command {
// makeCommandFunc executes the "make" command.
func makeCommandFunc(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")

View File

@ -38,7 +38,7 @@ func NewMakeDirCommand() cli.Command {
// makeDirCommandFunc executes the "mkdir" command.
func makeDirCommandFunc(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]
ttl := c.Int("ttl")

View File

@ -41,7 +41,7 @@ func NewRemoveCommand() cli.Command {
// removeCommandFunc executes the "rm" command.
func removeCommandFunc(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]
recursive := c.Bool("recursive")

View File

@ -35,7 +35,7 @@ func NewRemoveDirCommand() cli.Command {
// removeDirCommandFunc executes the "rmdir" command.
func removeDirCommandFunc(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]

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))
}

View File

@ -111,5 +111,4 @@ func getTransport(c *cli.Context) (*http.Transport, error) {
KeyFile: keyfile,
}
return transport.NewTransport(tls)
}