Better error for invalid argument count

This commit is contained in:
Florian Bruhin 2014-04-09 22:43:25 +02:00
parent 782242de04
commit 68413d8676
2 changed files with 6 additions and 4 deletions

View File

@ -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.

View File

@ -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