c-blake / cligen

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

How to use `--version`? #200

Closed brandonaut closed 2 years ago

brandonaut commented 2 years ago

How should I hook up a version value for my app to cligen's --version parameter? My first thought was that cligen would pull it from my nimble file, but when I build my app and run <myApp.exe> --version, I get Unknown version.

Apologies if I'm missing something obvious, I'm quite new to Nim and Nimble, and I'm not sure what the conventions are for these kinds of things.

c-blake commented 2 years ago

You have several options. See test/Version.nim

c-blake commented 2 years ago

And no apologies necessary. It's not very well documented, but I did try to name the test programs suggestively.

brandonaut commented 2 years ago

Perfect, thanks! I didn't realize there was a global clCfg object that I could modify.

c-blake commented 2 years ago

Yeah. Default global and can be overridden in dispatch, too.

Someone should really go through every test program and maybe create a little Wiki entry for the various features or an FAQ or something. Might make the answers more searchable. Github could have more StackOverflow like features, perhaps.

Anyway, glad you are off to the races. Good luck and feel free to ask any more Qs.