diff --git a/qutebrowser/commands/commands.py b/qutebrowser/commands/commands.py index 87e96683a..449c9b3fe 100644 --- a/qutebrowser/commands/commands.py +++ b/qutebrowser/commands/commands.py @@ -8,6 +8,8 @@ A command class can set the following properties: nargs -- Number of arguments. Either a number, '?' (0 or 1), '+' (1 or more), or '*' (any). Default: 0 + name -- The name of the command, or a list of aliases + split_args -- If arguments should be split or not. Default: True count -- If the command supports a count. Default: False @@ -32,6 +34,7 @@ class TabPrev(Command): nargs = 0 class Quit(Command): + name = ['quit', 'q'] nargs = 0 class Reload(Command): diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index 54beec931..550c9aeb1 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -20,7 +20,12 @@ def register_all(): qutebrowser.commands.commands, (lambda o: inspect.isclass(o) and o.__module__ == 'qutebrowser.commands.commands')): obj = cls() - cmd_dict[obj.name] = obj + if isinstance(obj.name, str): + names = [obj.name] + else: + names = obj.name + for n in names: + cmd_dict[n] = obj class CommandParser(QObject): """Parser for qutebrowser commandline commands""" @@ -33,9 +38,6 @@ class CommandParser(QObject): """Parses a command and runs its handler""" self.text = text parts = self.text.strip().split(maxsplit=1) - - # FIXME maybe we should handle unambigious shorthands for commands - # here? Or at least we should add :q for :quit. cmdstr = parts[0] try: cmd = cmd_dict[cmdstr] @@ -110,14 +112,18 @@ class Command(QObject): args -- Arguments to the command. count -- Command repetition count. """ - dbgout = ["command called:", self.name] + if isinstance(self.name, str): + name = self.name + else: + name = self.name[0] + dbgout = ["command called:", name] if args: dbgout += args if count is not None: dbgout.append("(count={})".format(count)) logging.debug(' '.join(dbgout)) - argv = [self.name] + argv = [name] if args is not None: argv += args self.signal.emit((count, argv))