mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: Add support for formating output of key related commands
All v2 key and dir related commands will now honor the global format option if it was specified. Otherwise, the output will remain the same.
This commit is contained in:
parent
640d511684
commit
205f10aeb6
@ -48,9 +48,12 @@ func mkdirCommandFunc(c *cli.Context, ki client.KeysAPI, prevExist client.PrevEx
|
||||
ttl := c.Int("ttl")
|
||||
|
||||
ctx, cancel := contextWithTotalTimeout(c)
|
||||
_, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: prevExist})
|
||||
resp, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: prevExist})
|
||||
cancel()
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
}
|
||||
if c.GlobalString("output") != "simple" {
|
||||
printResponseKey(resp, c.GlobalString("output"))
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,7 @@ func rmCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
if err != nil {
|
||||
handleError(ExitServerError, err)
|
||||
}
|
||||
|
||||
if !resp.Node.Dir {
|
||||
if !resp.Node.Dir || c.GlobalString("output") != "simple" {
|
||||
printResponseKey(resp, c.GlobalString("output"))
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func rmdirCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
handleError(ExitServerError, err)
|
||||
}
|
||||
|
||||
if !resp.Node.Dir {
|
||||
if !resp.Node.Dir || c.GlobalString("output") != "simple" {
|
||||
printResponseKey(resp, c.GlobalString("output"))
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,12 @@ func updatedirCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
||||
key := c.Args()[0]
|
||||
ttl := c.Int("ttl")
|
||||
ctx, cancel := contextWithTotalTimeout(c)
|
||||
_, err := ki.Set(ctx, key, "", &client.SetOptions{TTL: time.Duration(ttl) * time.Second, Dir: true, PrevExist: client.PrevExist})
|
||||
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)
|
||||
}
|
||||
if c.GlobalString("output") != "simple" {
|
||||
printResponseKey(resp, c.GlobalString("output"))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user