MCPcopy Create free account
hub / github.com/Hel10-Web/Databasetools / loopCmd

Function loopCmd

pac/redis_cmd.go:64–85  ·  view source on GitHub ↗

循环执行shell命令

(s string)

Source from the content-addressed store, hash-verified

62
63// 循环执行shell命令
64func loopCmd(s string) {
65 Info("执行命令")
66 reader := bufio.NewReader(os.Stdin)
67 for {
68 fmt.Print("$ ")
69 cmd, _ := reader.ReadString('\n')
70 cmd = strings.TrimRight(cmd, "\r\n")
71 if cmd == "exit" || cmd == "q" || cmd == "quit" {
72 if strings.Contains(s, "exec") {
73 CloseSlave("exec")
74 }
75 break
76 }
77 // 执行命令
78 if strings.Contains(s, "exec") {
79 RunCmd(cmd)
80 } else if strings.Contains(s, "lua") {
81 RedisLua(cmd)
82 }
83
84 }
85}
86
87// 循环执行 Redis 命令
88func loopRedis() {

Callers 1

HelpFunction · 0.85

Calls 4

InfoFunction · 0.85
CloseSlaveFunction · 0.85
RunCmdFunction · 0.85
RedisLuaFunction · 0.85

Tested by

no test coverage detected