From e9317f807bc029fafa7736d75c20669f470b7b79 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Apr 2014 07:02:24 +0200 Subject: [PATCH] Accept single int in register decorator for nargs --- qutebrowser/commands/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index 953f65d5e..7d819173c 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -18,6 +18,7 @@ """Contains various command utils and a global command dict.""" import inspect +from collections import Iterable from qutebrowser.commands.command import Command @@ -35,7 +36,7 @@ class register: Attributes: instance: The instance to be used as "self", as a dotted string. name: The name (as string) or names (as list) of the command. - nargs: A (minargs, maxargs) tuple of valid argument counts. + nargs: A (minargs, maxargs) tuple of valid argument counts, or an int. split_args: Whether to split the arguments or not. hide: Whether to hide the command or not. completion: Which completion to use for arguments, as a list of @@ -56,7 +57,10 @@ class register: self.name = name self.split_args = split_args self.hide = hide - self.nargs = nargs + if isinstance(nargs, Iterable) or nargs is None: + self.nargs = nargs + else: + self.nargs = (nargs, nargs) self.instance = instance self.completion = completion