add tstring spec type, string with trimmed consecutive spaces

This commit is contained in:
jesopo 2020-01-26 11:21:23 +00:00
parent 6169399b7e
commit 23d3ba5e29

View file

@ -39,6 +39,9 @@ class SpecArgumentTypeString(SpecArgumentType):
return "%s ..." % SpecArgumentType.name(self) return "%s ..." % SpecArgumentType.name(self)
def simple(self, args: typing.List[str]) -> typing.Tuple[typing.Any, int]: def simple(self, args: typing.List[str]) -> typing.Tuple[typing.Any, int]:
return " ".join(args), len(args) 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): class SpecArgumentTypeDuration(SpecArgumentType):
def name(self): def name(self):
@ -57,6 +60,7 @@ SPEC_ARGUMENT_TYPES = {
"word": SpecArgumentTypeWord, "word": SpecArgumentTypeWord,
"wordlower": SpecArgumentTypeWordLower, "wordlower": SpecArgumentTypeWordLower,
"string": SpecArgumentTypeString, "string": SpecArgumentTypeString,
"tstring": SpecArgumentTypeTrimString,
"duration": SpecArgumentTypeDuration "duration": SpecArgumentTypeDuration
} }