module Command: sig
.. end
command-line parsing with hierarchical sub-commands
module Flag: sig
.. end
type
t
abstract type of commands
val create : summary:string ->
usage_arg:string ->
init:(unit -> 'a) ->
flags:'a Flag.t list ->
anon:('a -> string list -> unit) ->
final:('a -> (unit -> string) -> 'b) -> main:('b -> int) -> t
create
constructs a base command from the following data:
'a
a mutable accumulator type for gathering arguments
'b
a composite argument type for the command, build from 'a
summary
a short description of what the command does
usage_arg
an abbreviation of the arguments it expects
init
a function that creates an mutable
accumulator of type 'accum
flags
a list of command line flags together with their
associated accumulator-mutating actions
anon
a function that runs on all anonymous arguments after
we scan through all the flags
final
a function that constructs the final argument
structure of type 'args
from the accumulated arguments.
The second argument to the function is a function which returns
the help for the command, which you can use when failing.
This function should raise an exception with some explanation
if it doesn't find all the arguments it expects.
main
the main function, parameterized by the argument structure
val group : summary:string -> (string * t) list -> t
group ~summary [...; (name_i, t_i); ...]
is an aggregate command
that dispatches to one of the named sub-commands. A "help"
sub-command will also be generated for the group.
val run : ?argv:string list -> t -> hash_bang_expand:bool -> int
Run the command against
Sys.argv
.
The labelled argument
hash_bang_expand
should be set to
true
when we
expect the command to run as the result of calling a #! interpreter script.
module Tab_completion: sig
.. end
module Version: sig
.. end