From 895db0145dd0722be8d0a37671e152dd9f0e0616 Mon Sep 17 00:00:00 2001 From: George Lemon Date: Mon, 8 Apr 2024 12:33:55 +0300 Subject: [PATCH] fix flagpos Signed-off-by: George Lemon --- src/kapsis/app.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kapsis/app.nim b/src/kapsis/app.nim index 94f0a30..50951fb 100644 --- a/src/kapsis/app.nim +++ b/src/kapsis/app.nim @@ -604,6 +604,7 @@ macro commands*(x: untyped, extras: untyped = nil) = let cmd: KapsisCommand = Kapsis.commands[id.key] # first check for available flags var i = 0 + var flagpos: seq[int] while i <= input.high: case input[i].kind of cmdLongOption, cmdShortOption: @@ -619,12 +620,14 @@ macro commands*(x: untyped, extras: untyped = nil) = collectInputData(inputValues, id.key, input[i].key, input[i].val, arg) add inputFlags, (input[i].key, input[i].val) - input.delete(i) + add flagpos, i inc i else: printError(unknownOption, input[i].key) quit(QuitFailure) else: inc i + for fp in flagpos: + input.delete(fp) case cmd.ctype of ctCmd: let argstype = Kapsis.commands[id.key].argsIndex