From c516efa800e9b5912a23a1291b03726c03f79679 Mon Sep 17 00:00:00 2001 From: siddontang Date: Wed, 3 Sep 2014 17:52:38 +0800 Subject: [PATCH] cli output pretty --- cmd/ledis-cli/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/ledis-cli/main.go b/cmd/ledis-cli/main.go index be509f3..ba97b30 100644 --- a/cmd/ledis-cli/main.go +++ b/cmd/ledis-cli/main.go @@ -105,13 +105,14 @@ func printReply(level int, reply interface{}) { case ledis.Error: fmt.Printf("%s", string(reply)) case []interface{}: - if level > 0 { - //todo for better pretty - fmt.Printf("%q", reply) - return - } for i, v := range reply { - fmt.Printf("%d) ", i+1) + if i != 0 { + fmt.Printf("%s", strings.Repeat(" ", level*4)) + } + + s := fmt.Sprintf("%d) ", i+1) + fmt.Printf("%-4s", s) + printReply(level+1, v) if i != len(reply)-1 { fmt.Printf("\n")