diff --git a/src/hwylterm/hwylcli.nim b/src/hwylterm/hwylcli.nim index 3254fe7..a520fa7 100644 --- a/src/hwylterm/hwylcli.nim +++ b/src/hwylterm/hwylcli.nim @@ -1069,6 +1069,11 @@ func genPosArgHandler(cfg: CliCfg, body: NimNode) = body.add quote do: result = @[`numArgs`..^1] + # first and last already absorbed the remaining args + elif maKind in [First, Last]: + body.add quote do: + result = @[] # args are ab + func addPostParseHook(cfg: CliCfg, body: NimNode) = ## generate block to set defaults and check for required flags let flagSet = ident"flagSet" diff --git a/tests/cli/tcli.nim b/tests/cli/tcli.nim index 3b1ae19..8f313e0 100644 --- a/tests/cli/tcli.nim +++ b/tests/cli/tcli.nim @@ -9,3 +9,5 @@ suite "hwylcli": checkRunWithArgs("posLastExact", "a b c d e", """first=a, second=b, third=@["c", "d", "e"]""") checkRunWithArgs("posNoMulti", "5 b c", """first=5, second=b, third=c""") checkRunWithArgs("posNoMulti", "5 b c d", """error missing positional args, got: 4, expected: 3""", code = 1) + checkRunWithArgs("enumFlag","--color red", "") + checkRunWithArgs("enumFlag","--color black", "")