Better error for invalid argument count
This commit is contained in:
parent
782242de04
commit
68413d8676
@ -81,7 +81,9 @@ class Command(QObject):
|
||||
pass
|
||||
else:
|
||||
raise ArgumentCountError("{}-{} args expected, but got {}".format(
|
||||
self.nargs[0], self.nargs[1], len(args)))
|
||||
self.nargs[0],
|
||||
self.nargs[1] if self.nargs[1] is not None else 'inf',
|
||||
len(args)))
|
||||
|
||||
def run(self, args=None, count=None):
|
||||
"""Run the command.
|
||||
|
@ -208,10 +208,10 @@ class CommandParser:
|
||||
try:
|
||||
self.parse(text)
|
||||
self._check()
|
||||
except ArgumentCountError:
|
||||
except ArgumentCountError as e:
|
||||
if ignore_exc:
|
||||
message.error("{}: invalid argument count".format(
|
||||
self._cmd.name))
|
||||
message.error("{}: invalid argument count - {}".format(
|
||||
self._cmd.name, str(e)))
|
||||
return False
|
||||
else:
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user