Accept single int in register decorator for nargs
This commit is contained in:
parent
c26430d08d
commit
e9317f807b
@ -18,6 +18,7 @@
|
|||||||
"""Contains various command utils and a global command dict."""
|
"""Contains various command utils and a global command dict."""
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
from collections import Iterable
|
||||||
|
|
||||||
from qutebrowser.commands.command import Command
|
from qutebrowser.commands.command import Command
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ class register:
|
|||||||
Attributes:
|
Attributes:
|
||||||
instance: The instance to be used as "self", as a dotted string.
|
instance: The instance to be used as "self", as a dotted string.
|
||||||
name: The name (as string) or names (as list) of the command.
|
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.
|
split_args: Whether to split the arguments or not.
|
||||||
hide: Whether to hide the command or not.
|
hide: Whether to hide the command or not.
|
||||||
completion: Which completion to use for arguments, as a list of
|
completion: Which completion to use for arguments, as a list of
|
||||||
@ -56,7 +57,10 @@ class register:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.split_args = split_args
|
self.split_args = split_args
|
||||||
self.hide = hide
|
self.hide = hide
|
||||||
|
if isinstance(nargs, Iterable) or nargs is None:
|
||||||
self.nargs = nargs
|
self.nargs = nargs
|
||||||
|
else:
|
||||||
|
self.nargs = (nargs, nargs)
|
||||||
self.instance = instance
|
self.instance = instance
|
||||||
self.completion = completion
|
self.completion = completion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user