Clap is a library for command-line argument parsing. Clap works by directly consuming arguments in an imperative way. Traditionally, argument parsing in OCaml is done by first defining a specification (an OCaml value defining the types of arguments), and then parsing from this specification. The “impure” approach of Clap skips the need to define a specification and results in code which is quite simple in practice, with limited boilerplate.
Clap is available as an opam package (opam install clap).
I did not know about minicli, thanks for the link!
Clap and minicli indeed share the same approach. Here are some differences I observed.
In minicli, the list of arguments is immutable; arguments are not consumed. It is “more pure”.
As a consequence, minicli does not seem to support unnamed arguments (also known as positional arguments).
As another consequence, in minicli each function takes the list of arguments, which makes it a bit more flexible at the cost of being slightly more verbose.
In minicli there is a hash table storing the list of seen arguments. It looks like this means that the immutable list of arguments must thus always be the same if you want to call finalize, which relies on this invariant.
minicli does not generate a --help (but it would be possible rather easily).
minicli considers that negative numbers are not option names, and is thus capable of handling them more naturally (in Clap you would need to escape the dash).
I think that minicli does not consider “-abc” to be equivalent to “-a -b -c”, whereas Clap differentiates short names (starting with a single dash and which can be factorize like that) and long names (starting with two dashes).
minicli’s source code is significantly shorter and thus simpler and easier to maintain.