"Bad enum value" response starts to and then doesn't list alternatives to the empty string
jrfondren opened this issue · 2 comments
jrfondren commented
This program:
import cligen
type E = enum
A, B, C
proc bug(e: E) =
echo e
dispatch bug
Responds with "one of: <nothing>" when a bad -e
is provided:
$ ./example -e
Bad enum value for option "e". "" is not one of:
Maybe you meant one of:
Run with --help for more details.
$ ./example -e=
Bad enum value for option "e". "" is not one of:
Maybe you meant one of:
Run with --help for more details.
$ ./example -e=?
Bad enum value for option "e". "?" is not one of:
A B C
Maybe you meant one of:
A
B
C
Bonus
There's probably no helping this one:
import cligen
type E = enum
A = ""
B = "B"
C = "C"
proc bug(e: E) =
echo e
dispatch bug
usage:
$ ./example -e=A
Bad enum value for option "e". "A" is not one of:
B C
Maybe you meant one of:
B
C
Run with --help for more details.
$ ./example -e=""
Bad enum value for option "e". "" is not one of:
Maybe you meant one of:
Run with --help for more details.
c-blake commented
Thanks for the report. I have reproduced this and will look at it in the coming hours.
c-blake commented
I think the current version control HEAD should work (even for your rather pathological empty enum string) case on Nim-0.20.2 up to nim-devel. E.g.,
type E = enum A = "", B = "B", C = "C"
proc bug(e: E) = echo len($e)
import cligen; dispatch bug
$ ./bug2 -e '' # produces "0\n"
If you need a release to test (e.g. via nimble) then I could punch one, but I'd probably prefer to wait a week or two. Let me know.