Remove explicit command name

This commit is contained in:
Florian Bruhin 2014-01-17 11:14:19 +01:00
parent 61c90f293c
commit 04140d9777
2 changed files with 7 additions and 12 deletions

View File

@ -8,35 +8,29 @@ class Empty(Command):
class Open(Command): class Open(Command):
nargs = 1 nargs = 1
name = 'open'
key = 'o' key = 'o'
signal = pyqtSignal(str) signal = pyqtSignal(str)
class TabOpen(Command): class TabOpen(Command):
nargs = 1 nargs = 1
name = 'tabopen'
key = 'Shift+o' key = 'Shift+o'
signal = pyqtSignal(str) signal = pyqtSignal(str)
class TabClose(Command): class TabClose(Command):
nargs = 0 nargs = 0
name = 'tabclose'
key = 'd' key = 'd'
signal = pyqtSignal() signal = pyqtSignal()
class TabNext(Command): class TabNext(Command):
nargs = 0 nargs = 0
name = 'tabnext'
key = 'Shift+j' key = 'Shift+j'
signal = pyqtSignal() signal = pyqtSignal()
class TabPrev(Command): class TabPrev(Command):
nargs = 0 nargs = 0
name = 'tabprev'
key = 'Shift+k' key = 'Shift+k'
signal = pyqtSignal() signal = pyqtSignal()
class Quit(Command): class Quit(Command):
nargs = 0 nargs = 0
name = 'quit'
signal = pyqtSignal() signal = pyqtSignal()

View File

@ -10,7 +10,12 @@ def register_all():
obj.__module__ == 'qutebrowser.commands.commands') obj.__module__ == 'qutebrowser.commands.commands')
for (name, cls) in inspect.getmembers(commands, is_cmd): for (name, cls) in inspect.getmembers(commands, is_cmd):
cls.bind() if cls.bind:
if cls.name is None:
name = cls.__name__.tolower()
else:
name = cls.name
cmd_dict[name] = cls()
class CommandParser(QObject): class CommandParser(QObject):
error = pyqtSignal(str) error = pyqtSignal(str)
@ -36,11 +41,7 @@ class Command(QObject):
name = None name = None
key = None key = None
signal = None signal = None
bind = True
@classmethod
def bind(cls):
if cls.name is not None:
cmd_dict[cls.name] = cls()
def check(self, argv): def check(self, argv):
if ((isinstance(self.nargs, int) and len(argv) != self.nargs) or if ((isinstance(self.nargs, int) and len(argv) != self.nargs) or