etcdctl: add --sort flag to ls command

This is a port of coreos/etcdctl#102
release-2.0
Pierre Phaneuf 2014-10-29 17:45:11 -07:00 committed by Brian Waldon
parent f61824ce01
commit 97597eca03
1 changed files with 3 additions and 1 deletions

View File

@ -12,6 +12,7 @@ func NewLsCommand() cli.Command {
Name: "ls",
Usage: "retrieve a directory",
Flags: []cli.Flag{
cli.BoolFlag{Name: "sort", Usage: "returns result in sorted order"},
cli.BoolFlag{Name: "recursive", Usage: "returns all values for key and child keys"},
},
Action: func(c *cli.Context) {
@ -43,9 +44,10 @@ func lsCommandFunc(c *cli.Context, client *etcd.Client) (*etcd.Response, error)
key = c.Args()[0]
}
recursive := c.Bool("recursive")
sort := c.Bool("sort")
// Retrieve the value from the server.
return client.Get(key, false, recursive)
return client.Get(key, sort, recursive)
}
// rPrint recursively prints out the nodes in the node structure.