support other default sep char

This commit is contained in:
Daylin Morgan 2024-11-19 14:39:27 -06:00
parent c5f70cec4e
commit ef573dc0f8
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 6 additions and 6 deletions

View file

@ -744,7 +744,7 @@ proc parse*(p: OptParser, target: var float) =
proc parse*[T](p: var OptParser, target: var seq[T]) = proc parse*[T](p: var OptParser, target: var seq[T]) =
checkVal p checkVal p
case p.sep case p.sep
of ",=": of ",=", ",:":
let baseVal = p.val let baseVal = p.val
for v in baseVal.split(","): for v in baseVal.split(","):
p.val = v.strip() p.val = v.strip()
@ -752,7 +752,7 @@ proc parse*[T](p: var OptParser, target: var seq[T]) =
var parsed: T var parsed: T
parse(p, parsed) parse(p, parsed)
target.add parsed target.add parsed
of "=", "": of "=",":","":
var parsed: T var parsed: T
parse(p, parsed) parse(p, parsed)
target.add parsed target.add parsed

View file

@ -72,16 +72,16 @@ hwylCli:
flags: flags:
^something ^something
thing: thing:
T KV[string, Color] T seq[KV[string, Color]]
? "some key value string" ? "some key value colors"
b: b:
T seq[float] T seq[float]
? "multiple floats" ? "multiple floats"
h "this will override the builtin 'h' for help"
def: def:
T string
? "a flag with a string default" ? "a flag with a string default"
* "the value" * "the value"
run: run:
echo "hello from `example b` command" echo "hello from `example b` command"
echo fmt"{thing=}, {b=}, {h=}, {def=}" echo fmt"{thing=}, {b=}, {def=}"