alan-turing-institute / whatwhat

A reimagining of nowwhat in OCaml
MIT License
0 stars 0 forks source link

Feature request: Help flag #106

Open jemrobinson opened 1 year ago

jemrobinson commented 1 year ago

Could you alias whatwhat -h to give the same information as whatwhat --help?

yongrenjie commented 1 year ago

This is... actually harder than I had hoped for!

At a simple level, it's not possible — the command-line parsing library we use (cmdliner) has --help hardcoded into it and not -h.

One option is to intercept Sys.argv and replace any instance of -h with --help, before passing it to cmdliner. (Specifically, we'd use Cmd.eval_value instead of Cmd.eval.)

That will have the desired effect, but also means that the actual help text displayed by whatwhat --help will be inconsistent (it will only show --help and not -h). In other words, we would like whatwhat --help to print

COMMON OPTIONS
       -h=[FMT], --help[=FMT] (default=auto)
           Show this help in format FMT. The value FMT must be one of auto,
           pager, groff or plain. With auto, the format is pager or plain
           whenever the TERM env var is dumb or undefined.

but it'll only print

COMMON OPTIONS
       --help[=FMT] (default=auto)
           Show this help in format FMT. The value FMT must be one of auto,
           pager, groff or plain. With auto, the format is pager or plain
           whenever the TERM env var is dumb or undefined.

The proper solution would be to fork cmdliner or use an alternative library, which is too much effort (unless I get a lot of free time :smile:)