c-blake / cligen

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

Remove dependency on pcre if possible #159

Closed genotrance closed 3 years ago

genotrance commented 3 years ago

Presuming commit introduced dependency on PCRE. Will be ideal to depend on nim-regex instead so that target machines no longer need PCRE installed.

c-blake commented 3 years ago

Yeah...I was made aware that very old MacOS and who knows what else may have no versions/inadequate versions of PCRE. I would prefer to be a 100% leaf dependency from a Nimble point of view since so many people just try out Nim with a little CLI app..I'd like to preserve the "git clone cligen; edit some file in top level and nim c x" and done possible workflow (or maybe add a --path:to-cligen).

I did a little work on changing the tiny subset of rST that I parse with regexes to a direct char-by-char parser, but I have not yet finished. We can leave this open as a reminder for me to finish. Unless you want to take a crack at that char-by-char parser? It might take me a week or three to get it done and I am open to PRs on this.

c-blake commented 3 years ago

I should perhaps also have said that I am aware of lib/packages/docutils/rst* in the Nim repository, but those libs are more or less hard-coded to do only HTML and Latex output. It might be conceivable to start from there and remove everything but single..triple-star and single|double-backquo, but I'm unsure that's any less work than doing the parser from scratch.

genotrance commented 3 years ago

For the near term, I'm fine using nimpcre and compile PCRE in. Is a two line change.

c-blake commented 3 years ago

Well, if you are ok with a PCRE dependency then I'm not sure what your exact issue is, but if you are fine patching your local cligen until I have something then cool. (Oh, and you id'd the wrong commit..It was 5564179fa53abe2d987f38fd423a0e7a2a70907b, not that it matters much. Word wrap algo is fully internal.)

genotrance commented 3 years ago

cligen is very popular and useful so depending on PCRE makes standalone binary distribution unnecessarily challenging. Most don't know about nimpcre or compiling PCRE in.

While I am impacted and I have a simple workaround, the community as a whole will benefit from your fix.

c-blake commented 3 years ago

Sure, sure. I was already working on it a little. I don't plan to drop the task and it doesn't seem that hard..(famous last words...). I doubt you looked at the regexes used, but none even use the zero or more/one or more constructs. They are all just char class-char-class-char class triples. Someone ought to write a "compiler" that translates stuff like that to a loops. Maybe someone already has... :-)

c-blake commented 3 years ago

I believe I have fixed this. Let me know if you think I have not. Also, while it is not a 100% legit rST parser, neither was the regex version. This new one matches the old exactly on about 40 CLI programs and several test files I tried. So, I think it's close enough for now.