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 ls command in json
The ls command will check for and honor json or extended output formats. Fixes #5993
This commit is contained in:
parent
e001848270
commit
f18d5433cc
@ -63,11 +63,16 @@ func lsCommandFunc(c *cli.Context, ki client.KeysAPI) {
|
|||||||
// printLs writes a response out in a manner similar to the `ls` command in unix.
|
// printLs writes a response out in a manner similar to the `ls` command in unix.
|
||||||
// Non-empty directories list their contents and files list their name.
|
// Non-empty directories list their contents and files list their name.
|
||||||
func printLs(c *cli.Context, resp *client.Response) {
|
func printLs(c *cli.Context, resp *client.Response) {
|
||||||
if !resp.Node.Dir {
|
if c.GlobalString("output") == "simple" {
|
||||||
fmt.Println(resp.Node.Key)
|
if !resp.Node.Dir {
|
||||||
}
|
fmt.Println(resp.Node.Key)
|
||||||
for _, node := range resp.Node.Nodes {
|
}
|
||||||
rPrint(c, node)
|
for _, node := range resp.Node.Nodes {
|
||||||
|
rPrint(c, node)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// user wants JSON or extended output
|
||||||
|
printResponseKey(resp, c.GlobalString("output"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user