aboutsummaryrefslogtreecommitdiff
path: root/src/utils/parse/spec.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-27 11:57:29 +0000
committerGravatar jesopo2020-01-27 12:13:10 +0000
commitd7cc7781bdb83682596c253a67889ffaeb6f60ef (patch)
tree4f020f84cc131d62f527eb76fa21fb1b62267810 /src/utils/parse/spec.py
parentadd "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.py9
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
}