cmdliner
cmdliner copied to clipboard
Enable creation of shortcircuiting options, like `--help` and `--version`
I just were in a situation where I wanted to create an alternative shortcircuiting option, lets call it --version-of-foo. From the interface there doesn't seem to be an elegant solution. Arguments for enabling this:
- My guess is that it can be a pretty common thing to want
- Feels weird to not be able to build the semantics that
Cmdlinerexposes via--helpand--version
There are certainly many different workarounds (e.g. process your Sys.argv before giving it to Cmdliner) and I don't have the feeling that's a "pretty common thing to want".
I'm not sure I want to add more complexity to Cmdliner's API for these niche usages.
I havn't dived into the implementation, but looking at the interface - might it be possible to make a function in inspired by Arg.required?:
val shortcircuiting : 'a option t -> 'a Term.t
Where, when option term evaluates to Some _, would shortcircuit, and otherwise not. This would not bring much complexity - but the question is if the underlying state easily supports this semantics.
... shortcircuiting getting a thunk to run as well
Not convinced by the need. Closing for now.