c-blake / cligen

Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at
https://c-blake.github.io/cligen/
ISC License
509 stars 24 forks source link

dispatchMulti Crashed at cligen.nim(730) (0.9.19) #102

Closed codehz closed 5 years ago

codehz commented 5 years ago

code: (from README)

proc foo(myMandatory: int, mynums: seq[int], foo=1, verb=false) =
  ##Some API call
proc bar(yippee: int, myfloats: seq[float], verb=false) =
  ##Some other API call
when isMainModule:
  import cligen; dispatchMulti([foo, help={"myMandatory": "Need it!"}], [bar])

result:

cligen.nim(730)          demo
fatal.nim(39)            sysFatal
Error: unhandled exception: index 1 not in 0 .. 0 [IndexError]

(PS: it works in 0.9.18)

c-blake commented 5 years ago

It also works for the version control HEAD, though I'm on a nim-devel version for the compiler. What Nim version are you testing with?

c-blake commented 5 years ago

Oh, never mind. I just got it to break with nim-devel and that v0.19.19 version of cligen. Let me look into it a bit.

c-blake commented 5 years ago

Ok. I think the issue comes from https://github.com/c-blake/cligen/commit/8d072de0a82eed1c57cb2b7b0d6c2f72d285da58 . If you used an older Nim compiler like 0.19.2 then the last release of cligen might work, or alternatively if you are using a new Nim compiler then you should use the VC head (or any version after the commit mentioned above) of cligen. ( I am planning on punching a new 0.19.20 release of cligen soon, but have an interface related to helpCase I probably want to change before that. ) I hope this helps.

c-blake commented 5 years ago

Also, you aren't the only one who tripped this problem. https://github.com/c-blake/cligen/issues/101 also had it, but they had luck just clearing out their nim compiler cache. Anyway, since I am pretty sure this is just a version-compatibility problem, I am closing this issue. I should stamp a cligen 0.19.20 in the next few days. Then the answer will be the simpler "use the latest release if you're using a recent Nim" instead of use the VC #head.