[commands] Add param attribute to MissingRequiredArgument
This should allow easier querying on what argument is missing. Fixes #470.
This commit is contained in:
parent
47ef657fbd
commit
7bc3750c27
@ -226,7 +226,7 @@ class Command:
|
|||||||
if param.kind == param.VAR_POSITIONAL:
|
if param.kind == param.VAR_POSITIONAL:
|
||||||
raise RuntimeError() # break the loop
|
raise RuntimeError() # break the loop
|
||||||
if required:
|
if required:
|
||||||
raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
|
raise MissingRequiredArgument(param)
|
||||||
return param.default
|
return param.default
|
||||||
|
|
||||||
if consume_rest_is_special:
|
if consume_rest_is_special:
|
||||||
|
@ -68,8 +68,15 @@ class CommandNotFound(CommandError):
|
|||||||
class MissingRequiredArgument(UserInputError):
|
class MissingRequiredArgument(UserInputError):
|
||||||
"""Exception raised when parsing a command and a parameter
|
"""Exception raised when parsing a command and a parameter
|
||||||
that is required is not encountered.
|
that is required is not encountered.
|
||||||
|
|
||||||
|
Attributes
|
||||||
|
-----------
|
||||||
|
param: str
|
||||||
|
The argument that is missing.
|
||||||
"""
|
"""
|
||||||
pass
|
def __init__(self, param):
|
||||||
|
self.param = param.name
|
||||||
|
super().__init__('{0.name} is a required argument that is missing.'.format(param))
|
||||||
|
|
||||||
class TooManyArguments(UserInputError):
|
class TooManyArguments(UserInputError):
|
||||||
"""Exception raised when the command was passed too many arguments and its
|
"""Exception raised when the command was passed too many arguments and its
|
||||||
|
Loading…
x
Reference in New Issue
Block a user