From 97597eca039af156c563242b3a3d1a07c96c1126 Mon Sep 17 00:00:00 2001 From: Pierre Phaneuf Date: Wed, 29 Oct 2014 17:45:11 -0700 Subject: [PATCH] etcdctl: add --sort flag to ls command This is a port of coreos/etcdctl#102 --- etcdctl/command/ls_command.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etcdctl/command/ls_command.go b/etcdctl/command/ls_command.go index 7f15fd718..59ae652e2 100644 --- a/etcdctl/command/ls_command.go +++ b/etcdctl/command/ls_command.go @@ -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.