mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 03:00:43 -06:00
add seq separator support
This commit is contained in:
parent
938131c6cd
commit
748f7e1bd6
1 changed files with 16 additions and 4 deletions
|
@ -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
|
||||||
|
case p.sep
|
||||||
|
of ",=":
|
||||||
|
let baseVal = p.val
|
||||||
|
for v in baseVal.split(","):
|
||||||
|
p.val = v.strip()
|
||||||
|
if p.val == "": continue
|
||||||
var parsed: T
|
var parsed: T
|
||||||
parse(p, parsed)
|
parse(p, parsed)
|
||||||
target.add 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
|
||||||
|
|
Loading…
Reference in a new issue