Use shlex to split command args, add split_args property
This commit is contained in:
parent
2d8fd4499d
commit
bd28c00cf1
@ -4,10 +4,12 @@ from qutebrowser.commands.utils import Command
|
||||
class Open(Command):
|
||||
nargs = 1
|
||||
key = 'o'
|
||||
split_args = False
|
||||
|
||||
class TabOpen(Command):
|
||||
nargs = 1
|
||||
key = 'O'
|
||||
split_args = False
|
||||
|
||||
class TabClose(Command):
|
||||
nargs = 0
|
||||
|
@ -21,14 +21,20 @@ class CommandParser(QObject):
|
||||
error = pyqtSignal(str)
|
||||
|
||||
def parse(self, text):
|
||||
parts = text.strip().split()
|
||||
parts = text.strip().split(maxsplit=1)
|
||||
|
||||
cmd = parts[0]
|
||||
args = parts[1:]
|
||||
try:
|
||||
obj = cmd_dict[cmd]
|
||||
except KeyError:
|
||||
self.error.emit("{}: no such command".format(cmd))
|
||||
return
|
||||
|
||||
if obj.split_args:
|
||||
args = shlex.split(parts[1])
|
||||
else:
|
||||
args = [parts[1]]
|
||||
|
||||
try:
|
||||
obj.check(args)
|
||||
except TypeError:
|
||||
@ -43,6 +49,7 @@ class Command(QObject):
|
||||
signal = None
|
||||
count = False
|
||||
bind = True
|
||||
split_args = True
|
||||
signal = pyqtSignal(tuple)
|
||||
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user