add seq separator support

This commit is contained in:
Daylin Morgan 2024-11-18 13:58:44 -06:00
parent 938131c6cd
commit 748f7e1bd6
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -741,11 +741,23 @@ proc parse*(p: OptParser, target: var float) =
"failed to parse value for [b]" & p.key & "[/] as float: [b]" & p.val "failed to parse value for [b]" & p.key & "[/] as float: [b]" & p.val
) )
proc parse*[T](p: OptParser, target: var seq[T]) = proc parse*[T](p: var OptParser, target: var seq[T]) =
checkVal p checkVal p
var parsed: T case p.sep
parse(p, parsed) of ",=":
target.add parsed let baseVal = p.val
for v in baseVal.split(","):
p.val = v.strip()
if p.val == "": continue
var parsed: T
parse(p, parsed)
target.add parsed
of "=", "":
var parsed: T
parse(p, parsed)
target.add parsed
else: assert false
proc parse*(p: OptParser, target: var Count) = proc parse*(p: OptParser, target: var Count) =
# if value set to that otherwise increment # if value set to that otherwise increment