add structure to handle SockCmd

This commit is contained in:
Dan Ballard 2015-01-27 08:19:38 -08:00
parent 92e16f322e
commit 671436e8e0
2 changed files with 11 additions and 0 deletions

BIN
cmd/warrend/.main.go.swo Normal file

Binary file not shown.

View File

@ -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))
}