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

Sync `clCfg.version` with package #213

Closed eggplants closed 2 years ago

eggplants commented 2 years ago

I would like to set package's version to clCfg.version. Is it possible?

c-blake commented 2 years ago

I am not sure exactly what you want, but I suspect test/Version.nim has the answers you seek. Let me know if it doesn't.

eggplants commented 2 years ago

What I've been looking for. Thank you!

c-blake commented 2 years ago

You are welcome! There really are quite a lot of features only "described" (if you can call it that) in those test programs.

This is more advanced, but you might want to concatenate versions both for yourself and the transitive closure of all your dependencies. For example, on unix that git describe fork could instead do git describe ..; cd WhereCligenIs; git describe .. to concatenate your package version with the cligen version..or any of your other dependencies, really. Or you could collect them in strings and & them together at compile time.

The only trick is "WhereCligenIs" or if it's even a git repo. That is not a cligen-specific issue. At best I could provide a global const you reference and & in. As flattered as I would be, cligen is unlikely to stay your only ever dependency. :-) A lot of people would probably like to compile in a version string of the transitive closure of all their dependencies even if they do not use cligen. So, a more general solution is the best way here.

Maybe there should be (or is) a nimble showDepTree? Or one of the several other Nim package managers, perhaps (Atlas, nimph, etc.)? I could add it to nimp, but I think I might be its only user.

Anything like that would let you run that command instead of the git describe command. You can probably do whatever string post-processing you need at compile-time. This feels like a question IRCs or the Nim Forum might be better at answering than I am. If you find a way to do that, I'm happy to put it on the Wiki if you post it here, or even inside test/Version.nim as another when fork. I haven't searched, but I feel like it may have come up before in cligen issues...