From 748f7e1bd6325d39bc531b29ce28f5ef276c5aae Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 18 Nov 2024 13:58:44 -0600 Subject: [PATCH] add seq separator support --- src/hwylterm/hwylcli.nim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/hwylterm/hwylcli.nim b/src/hwylterm/hwylcli.nim index 28fa01e..8d67359 100644 --- a/src/hwylterm/hwylcli.nim +++ b/src/hwylterm/hwylcli.nim @@ -741,11 +741,23 @@ proc parse*(p: OptParser, target: var float) = "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 - var parsed: T - parse(p, parsed) - target.add parsed + case p.sep + of ",=": + 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) = # if value set to that otherwise increment