etcdctl/ctlv2: error handling with JSON

This commit is contained in:
Gyu-Ho Lee
2016-11-01 19:52:42 -07:00
parent 71bad561e8
commit 9b470ef4c0
14 changed files with 42 additions and 29 deletions

View File

@ -41,7 +41,7 @@ func NewUpdateDirCommand() cli.Command {
// updatedirCommandFunc executes the "updatedir" command.
func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
if len(c.Args()) == 0 {
handleError(ExitBadArgs, errors.New("key required"))
handleError(c, ExitBadArgs, errors.New("key required"))
}
key := c.Args()[0]
ttl := c.Int("ttl")
@ -49,7 +49,7 @@ func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: client.PrevExist})
cancel()
if err != nil {
handleError(ExitServerError, err)
handleError(c, ExitServerError, err)
}
if c.GlobalString("output") != "simple" {
printResponseKey(resp, c.GlobalString("output"))