1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 21:44:21 +00:00

Add optional to CommandArgs

This commit is contained in:
Steffo 2019-04-09 12:17:05 +02:00
parent 4735d145b6
commit 8f7fe39c27

View file

@ -43,6 +43,11 @@ class CommandArgs(list):
raise InvalidInputError("Pattern didn't match") raise InvalidInputError("Pattern didn't match")
return match return match
def optional(self, index: int) -> typing.Optional:
try:
return self[index]
except IndexError:
return None
class Command: class Command:
"""A generic command, called from any source.""" """A generic command, called from any source."""