Use shlex for console parsing.
parent
052ef59e3f
commit
fdcde7be8f
|
@ -1,5 +1,6 @@
|
|||
import logic
|
||||
import sys
|
||||
import shlex
|
||||
|
||||
actions = {
|
||||
"initialize": (logic.initialize, [], True),
|
||||
|
@ -19,7 +20,7 @@ def start():
|
|||
sys.stdout.write("> ")
|
||||
sys.stdout.flush()
|
||||
line = raw_input().strip()
|
||||
command = line.split()[0]
|
||||
command = shlex.split(line)[0]
|
||||
|
||||
if command == "quit":
|
||||
break
|
||||
|
@ -42,7 +43,7 @@ def start():
|
|||
print "[e] Make up your mind."
|
||||
continue
|
||||
|
||||
given_arguments = line.split()[1:]
|
||||
given_arguments = shlex.split(line)[1:]
|
||||
if len(given_arguments) != len(arguments):
|
||||
print "[e] Syntax: %s %s" % (command, " ".join([argument[0] for argument in arguments]))
|
||||
continue
|
||||
|
|
Reference in New Issue