diff options
| author | 2020-01-27 11:57:29 +0000 | |
|---|---|---|
| committer | 2020-01-27 12:13:10 +0000 | |
| commit | d7cc7781bdb83682596c253a67889ffaeb6f60ef (patch) | |
| tree | 4f020f84cc131d62f527eb76fa21fb1b62267810 /src/utils/parse/spec.py | |
| parent | add "additional word" (`aword`) command arument spec type (diff) | |
| signature | ||
add 'int' command arg spec type
Diffstat (limited to 'src/utils/parse/spec.py')
| -rw-r--r-- | src/utils/parse/spec.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/utils/parse/spec.py b/src/utils/parse/spec.py index 0fb25aca..a52dc969 100644 --- a/src/utils/parse/spec.py +++ b/src/utils/parse/spec.py @@ -1,6 +1,6 @@ import enum, typing from .time import duration -from . import try_int +from .types import try_int class SpecArgumentContext(enum.IntFlag): CHANNEL = 1 @@ -49,6 +49,12 @@ class SpecArgumentTypeTrimString(SpecArgumentTypeString): def simple(self, args: typing.List[str]): return SpecArgumentTypeString.simple(self, list(filter(None, args))) +class SpecArgumentTypeInt(SpecArgumentType): + def simple(self, args): + if args: + return try_int(args[0]), 1 + return None, 1 + class SpecArgumentTypeDuration(SpecArgumentType): def name(self): return "+%s" % (SpecArgumentType.name(self) or "duration") @@ -68,6 +74,7 @@ SPEC_ARGUMENT_TYPES = { "wordlower": SpecArgumentTypeWordLower, "string": SpecArgumentTypeString, "tstring": SpecArgumentTypeTrimString, + "int": SpecArgumentTypeInt, "duration": SpecArgumentTypeDuration } |
