add structure to handle SockCmd
This commit is contained in:
parent
92e16f322e
commit
671436e8e0
Binary file not shown.
|
@ -7,6 +7,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
@ -37,8 +38,18 @@ func sockCmdHandle(c net.Conn) {
|
|||
}
|
||||
fmt.Println("cmdHandle got command:", string(data))
|
||||
|
||||
// BAD: TODO: handle quotes "
|
||||
var args = strings.Split(" ", data)
|
||||
|
||||
// parse args
|
||||
var icmd = warren.GetCommand(args[0])
|
||||
// get and run cmd
|
||||
if icmd == nil {
|
||||
c.Write([]byte("Unknown command " + args[0]))
|
||||
// usage ?
|
||||
return
|
||||
}
|
||||
icmd.(*SockCommand).Exec(c, args[1:])
|
||||
|
||||
c.Write([]byte("echo: " + data))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue