c-blake / cligen

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

No error for passing non-static table to `help` or `short` of `dispatch` #208

Closed ZoomRmc closed 2 years ago

ZoomRmc commented 2 years ago
import cligen, tables

const
  aH = "foo"
  bH = "bar"

let HelpS = {
      "a": aH,
      "b": bH,
  }.toTable()

proc main(a: string; b: int) =
  quit()

when isMainModule:
  dispatch(main, help = HelpS)

Runtime error:

cligen.nim(371, 25) dispatchGen
cligen.nim(198, 35) parseHelps
test.nim(16, 11) template/generic instantiation of `dispatch` from here
cligen.nim(829, 14) template/generic instantiation of `dispatchCf` from here
cligen.nim(816, 14) template/generic instantiation of `dispatchGen` from here
cligen.nim(198, 35) Error: cannot get child of node kind: nnkEmpty

Same goes for the short parameter.

cligen v1.5.23

c-blake commented 2 years ago

I think I can either make this work or at least generate a better error message, but give me a little while to work on it.