Handle whitespace correctly when splitting with flags.

Fixes #248.
This commit is contained in:
Florian Bruhin 2014-11-10 08:14:45 +01:00
parent 1b46c96192
commit 96c72724ce

View File

@ -216,10 +216,11 @@ class CommandRunner(QObject):
try: try:
self._cmd = cmdutils.cmd_dict[cmdstr] self._cmd = cmdutils.cmd_dict[cmdstr]
except KeyError: except KeyError:
if fallback: if fallback and keep:
# FIXME test this
cmdstr, sep, argstr = text.partition(' ') cmdstr, sep, argstr = text.partition(' ')
return [cmdstr, sep] + argstr.split(' ') return [cmdstr, sep] + argstr.split()
elif fallback:
return text.split()
else: else:
raise cmdexc.NoSuchCommandError( raise cmdexc.NoSuchCommandError(
'{}: no such command'.format(cmdstr)) '{}: no such command'.format(cmdstr))
@ -258,11 +259,11 @@ class CommandRunner(QObject):
# 0 1 2 3 # 0 1 2 3
# second split: ['--foo', '-v', 'bar baz'] # second split: ['--foo', '-v', 'bar baz']
# (maxsplit=2) # (maxsplit=2)
split_args = split.simple_split(argstr, keep=True) split_args = split.simple_split(argstr, keep=keep)
for i, arg in enumerate(split_args): for i, arg in enumerate(split_args):
arg = arg.strip() arg = arg.strip()
if not arg.startswith('-'): if not arg.startswith('-'):
self._args = split.simple_split(argstr, keep=True, self._args = split.simple_split(argstr, keep=keep,
maxsplit=i) maxsplit=i)
break break
else: else: