mirror of https://github.com/ledisdb/ledisdb.git
use regexp to handle cli command
This commit is contained in:
parent
4b37a88a9d
commit
785168e8cd
|
@ -1,11 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "bufio"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/siddontang/ledisdb/client/go/ledis"
|
"github.com/siddontang/ledisdb/client/go/ledis"
|
||||||
// "os"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,6 +28,8 @@ func main() {
|
||||||
|
|
||||||
setHistoryCapacity(100)
|
setHistoryCapacity(100)
|
||||||
|
|
||||||
|
reg, _ := regexp.Compile(`'.*?'|".*?"|\S+`)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
cmd, err := line(fmt.Sprintf("%s> ", cfg.Addr))
|
cmd, err := line(fmt.Sprintf("%s> ", cfg.Addr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -36,7 +37,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds := strings.Fields(cmd)
|
cmds := reg.FindAllString(cmd, -1)
|
||||||
if len(cmds) == 0 {
|
if len(cmds) == 0 {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue