func firstArgIdx(cmd: CmdInfo): int =
# This will work correctly only if the command has arguments.
result = cmd.opts.len - 1
while result > 0:
if cmd.opts[result - 1].kind != Arg:
return
which needs the addition of
else:
result -= 1
to prevent an infinite loop.
Even this relies on the convention that arguments are defined last to produce a correct help message.
Parsing the command line seems to work correctly if this convention is not followed, but the help message doesn't mention any such arguments.
A related but purely cosmetic issue is that there is no space between the description of one argument and the name of the next.
I would suggest amending describeInvocation to add
The problem is in:
which needs the addition of
to prevent an infinite loop. Even this relies on the convention that arguments are defined last to produce a correct help message. Parsing the command line seems to work correctly if this convention is not followed, but the help message doesn't mention any such arguments.
A related but purely cosmetic issue is that there is no space between the description of one argument and the name of the next. I would suggest amending
describeInvocation
to addto the end of the block starting