forked from mirror/ledisdb
move redid-cli to cmd
This commit is contained in:
parent
d85d65d0f2
commit
8721bf410b
|
@ -40,13 +40,13 @@ func main() {
|
||||||
} else {
|
} else {
|
||||||
args := make([]interface{}, len(cmds[1:]))
|
args := make([]interface{}, len(cmds[1:]))
|
||||||
for i := range args {
|
for i := range args {
|
||||||
args[i] = cmds[1+i]
|
args[i] = strings.Trim(string(cmds[1+i]), "\"")
|
||||||
}
|
}
|
||||||
r, err := c.Do(cmds[0], args...)
|
r, err := c.Do(cmds[0], args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s", err.Error())
|
fmt.Printf("%s", err.Error())
|
||||||
} else {
|
} else {
|
||||||
printReply(r)
|
printReply(cmd, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
|
@ -54,16 +54,16 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printReply(reply interface{}) {
|
func printReply(cmd string, reply interface{}) {
|
||||||
switch reply := reply.(type) {
|
switch reply := reply.(type) {
|
||||||
case int64:
|
case int64:
|
||||||
fmt.Printf("(integer) %d", reply)
|
fmt.Printf("(integer) %d", reply)
|
||||||
case string:
|
case string:
|
||||||
fmt.Printf("%q", reply)
|
fmt.Printf("%s", reply)
|
||||||
case []byte:
|
case []byte:
|
||||||
fmt.Printf("%q", reply)
|
fmt.Printf("%s", string(reply))
|
||||||
case nil:
|
case nil:
|
||||||
fmt.Printf("(empty list or set)")
|
fmt.Printf("(nil)")
|
||||||
case ledis.Error:
|
case ledis.Error:
|
||||||
fmt.Printf("%s", string(reply))
|
fmt.Printf("%s", string(reply))
|
||||||
case []interface{}:
|
case []interface{}:
|
Loading…
Reference in New Issue