Is Ocaml a good language to create a CLI in? It is usually less about the language and more about the available libraries. As a newcomer to Ocaml and CLI development overall, it is hard for me to judge this.
So how do Ocaml CLI libraries fare against those in other programming languages? are they just as easy? are they just as powerful and flexible? are they even better?
The “gold standard” is cmdliner I would say - it can do an awful lot for you. It is very declarative and heavily typed so if you aren’t familiar with that style of library then perhaps build up in small steps. I’d agree with nojb that the tutorial and examples are well done too.
I must admit for a lot of the little utilities I’ve been writing I have been getting away with Stdlib.Arg. It it a lot smaller and tends towards mutable state etc. but is very easy to get started with and handles all the basics.
I am the author of minicli, because I was tired w/ Stdlib.Arg and did not like the alternatives:
minicli was created w/ scientific applications in mind.
It is very explicit about what it does and crashes early and lound in case anything fishy is happening.
minicli is minimalist though, so if you are looking to automatically generate a manpage
from the CLI options you are declaring in your program, this is not going to cut it.
But hey, do one thing and do it well…
That’s a bit misplaced. Cmdliner also does one thing and does it well: abstract away command line parsing according to established standards with good error reporting.
But since to do so you need to specify a bit of metadata why not exploit it to its full extent for the benefit of everyone ? A library that wouldn’t do that would be a waste of my time ;–)