cli output pretty

This commit is contained in:
siddontang 2014-09-03 17:52:38 +08:00
parent 0f4c628146
commit c516efa800
1 changed files with 7 additions and 6 deletions

View File

@ -105,13 +105,14 @@ func printReply(level int, reply interface{}) {
case ledis.Error: case ledis.Error:
fmt.Printf("%s", string(reply)) fmt.Printf("%s", string(reply))
case []interface{}: case []interface{}:
if level > 0 {
//todo for better pretty
fmt.Printf("%q", reply)
return
}
for i, v := range reply { 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) printReply(level+1, v)
if i != len(reply)-1 { if i != len(reply)-1 {
fmt.Printf("\n") fmt.Printf("\n")