Skip to content

Commit

Permalink
fix flagpos
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <[email protected]>
  • Loading branch information
georgelemon committed Apr 8, 2024
1 parent 1305810 commit 895db01
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kapsis/app.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 895db01

Please sign in to comment.