more hwylcli tests

This commit is contained in:
Daylin Morgan 2025-01-06 12:37:31 -06:00
parent 4fd2a249a3
commit bc4a0a32e9
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 7 additions and 0 deletions

View file

@ -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"

View file

@ -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", "")