Refactored command parsing tokenization.
parent
194b2c4965
commit
c812aaa36b
|
@ -190,14 +190,7 @@ Loop:
|
||||||
// ParseCommand parses an instruction and calls related method, if any
|
// ParseCommand parses an instruction and calls related method, if any
|
||||||
func (c *CommandLine) ParseCommand(cmd string) bool {
|
func (c *CommandLine) ParseCommand(cmd string) bool {
|
||||||
lcmd := strings.TrimSpace(strings.ToLower(cmd))
|
lcmd := strings.TrimSpace(strings.ToLower(cmd))
|
||||||
|
tokens := strings.Fields(lcmd)
|
||||||
split := strings.Split(lcmd, " ")
|
|
||||||
var tokens []string
|
|
||||||
for _, token := range split {
|
|
||||||
if token != "" {
|
|
||||||
tokens = append(tokens, token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(tokens) > 0 {
|
if len(tokens) > 0 {
|
||||||
switch tokens[0] {
|
switch tokens[0] {
|
||||||
|
|
Loading…
Reference in New Issue