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

Error suppressing shortopt #124

Closed pb-cdunn closed 4 years ago

pb-cdunn commented 4 years ago

To suppress some long option getting any short option, specify '\0' as the value for its short key.

I've used that before, but now I'm having trouble with it.

short = {"wl-fn": '\0', "input-fn": 'i', "output-fn": 'o'},
stack trace: (most recent call last)
/pbi/flash/cdunn/repo/falconc/nimbleDir/pkgs/cligen-0.9.37/cligen.nim(277, 23) dispatchGen
/pbi/flash/cdunn/gh/Nim/lib/pure/collections/tables.nim(669, 11) dupBlock
/pbi/flash/cdunn/gh/Nim/lib/system/assertions.nim(27, 20) failedAssertImpl
/pbi/flash/cdunn/gh/Nim/lib/system/assertions.nim(20, 11) raiseAssert
/pbi/flash/cdunn/gh/Nim/lib/system/fatal.nim(39, 5) sysFatal
/pbi/flash/cdunn/repo/falconc/src/falconc.nim(40, 18) template/generic instantiation of `dispatchMulti` from here
/pbi/flash/cdunn/repo/falconc/src/falconc.nim(41, 10) template/generic instantiation of `dispatchMultiGen` from here
/pbi/flash/cdunn/repo/falconc/src/falconc.nim(72, 33) template/generic instantiation of `dispatchGen` from here
/pbi/flash/cdunn/gh/Nim/lib/system/fatal.nim(39, 5) Error: unhandled exception: /pbi/flash/cdunn/gh/Nim/lib/pure/collections/tables.nim(669, 13) `len(t) ==
    L` the length of the table changed while iterating over it [AssertionError]

But this works fine:

 72         [rotate.main, cmdName = "circ-orient",
 73             short = {"wl-fn": 'w', "input-fn": 'i', "output-fn": 'o'},
 75             help = {
 76         "input-fn": "fasta (or fastq) file of circular sequences",
 77         "output-fn": "fasta (or fastq) file output",
 78         "wl-fn": "white list of sequences to rotate, one per line, no spaces, no trailing spaces",
 79         "window": "window size to caculate gc-skew",
 80         "step": "window step",
 81         "print": "print skew data to files ('SEQ.gc_skew.txt'), one per sequence"
 82             },
 83         ],

All I changed is '\0' to 'w'.

So the best I can do is to assign w to a different long-option.

c-blake commented 4 years ago

This table change while iterating has come up before. It's probably a simple fix (and maybe even a real caught bug). Give me a bit.

c-blake commented 4 years ago

Oh, wait...Maybe this is already fixed? I just saw cligen v0.9.37 in your trace.

c-blake commented 4 years ago

I.e., I think this commit fixed this problem with an explanation in the commit message: https://github.com/c-blake/cligen/commit/0c7a2b9c0f9ceb12d73b424328bc9ccab4efc47b#diff-5cbfc5f8e7ea060286d1849ee868c3de

To elaborate a little, I think it's probably a "bug" in Nim -- at least a think-O -- but never filed an issue on it. I feel like let tmp = result should allow writing to result without stomping on the let. It could also be a bug in how Table tries to detect modification inside a loop. I just worked around it rather than diving into it.

Anyway, close this issue when you confirm that's your already fixed problem. Thanks.

c-blake commented 4 years ago

I think this is already fixed and you aren't replying. So, I am closing.

pb-cdunn commented 4 years ago

Yes, that worked.