aboutsummaryrefslogtreecommitdiff
path: root/src/utils/parse
diff options
context:
space:
mode:
authorGravatar jesopo2020-01-26 11:21:23 +0000
committerGravatar jesopo2020-01-26 11:24:57 +0000
commit23d3ba5e29a92b31cfbca32721836fbb6075ecd1 (patch)
treebc9d0b1ec4052510a5475543f4e251aa275a42e5 /src/utils/parse
parentupdate karma.py to use command spec (diff)
signature
add tstring spec type, string with trimmed consecutive spaces
Diffstat (limited to 'src/utils/parse')
-rw-r--r--src/utils/parse/spec.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/parse/spec.py b/src/utils/parse/spec.py
index bb0dcc9d..46ab9ad5 100644
--- a/src/utils/parse/spec.py
+++ b/src/utils/parse/spec.py
@@ -39,6 +39,9 @@ class SpecArgumentTypeString(SpecArgumentType):
return "%s ..." % SpecArgumentType.name(self)
def simple(self, args: typing.List[str]) -> typing.Tuple[typing.Any, int]:
return " ".join(args), len(args)
+class SpecArgumentTypeTrimString(SpecArgumentTypeString):
+ def simple(self, args: typing.List[str]):
+ return SpecArgumentTypeString.simple(self, list(filter(None, args)))
class SpecArgumentTypeDuration(SpecArgumentType):
def name(self):
@@ -57,6 +60,7 @@ SPEC_ARGUMENT_TYPES = {
"word": SpecArgumentTypeWord,
"wordlower": SpecArgumentTypeWordLower,
"string": SpecArgumentTypeString,
+ "tstring": SpecArgumentTypeTrimString,
"duration": SpecArgumentTypeDuration
}