Library
Module
Module type
Parameter
Class
Class type
Command Line Interface Maker
type 'a conv = 'a Cmdliner.Arg.conv
Converter type from Cmdliner
.
Flags are boolean values which don't need value: only their presence (true
) or not (false
) give their value.
flag ~docs ~doc ~env aka
defines a new flag whose names are given in aka
.
Optional arguments are the usual argument specified by a -x
or --xxx
notation on command line.
val opt :
?docs:string ->
?docv:string ->
?doc:string ->
?env:string ->
?vopt:'a ->
'a conv ->
'a ->
string list ->
('a, spec) arg
opt ~docs ~docv ~doc ~env ~vopt conv default aka
defines a new optional argument whose names are given in aka
.
val opt_all :
?docs:string ->
?docv:string ->
?doc:string ->
?env:string ->
?vopt:'a ->
'a conv ->
'a list ->
string list ->
('a list, spec) arg
opt_all ~docs ~docv ~doc ~env ~vopt conv default aka
same as opt
but gathers several invocations of the options into a list. For example, this is useful for include directory options used in many tools.
Positional arguments have no name and are supposely mandatory and ordered on command line.
For now, positional arguments combinators are somehow illformed and will be modified in near future so use it carefuly.
To finalize an argument, the following constraints can be used.
required a
ensures that argument a
holding a optional value is given on command line.
non_empty a
ensures that argument a
holding a list is not empty.
last a
ensures that only the last given value on command line will be used for a
.
Configurations hold the command line argument to be used.
val create : unit -> cfg
Creates an empty configuration.
register cfg arg
registers the argument arg
info cfg
and returns a getter to the option's value.
Since commands can have multiple related environment variable, we inherit their definitions from Cmdliner
.
type env = Cmdliner.Term.env_info
Environment variable specification type.
val env : ?docs:string -> ?doc:string -> string -> env
env ~docs ~doc name
creates a ne environment variable specification named name
.
type 'a command = {
cfg : cfg;
The related configuration.
*)cmd : unit -> 'a;
The command entrypoint.
*)man_xrefs : Cmdliner.Manpage.xref list;
Man references.
*)man : Cmdliner.Manpage.block list;
Additional man documentation.
*)envs : env list;
Environment variables.
*)doc : string;
Main documentation.
*)version : string option;
Version (if any).
*)name : string;
Binary name.
*)}
The command type. It gathers all Cmdliner
related informations into one simle data structure.
val command :
?cfg:cfg ->
?man_xrefs:Cmdliner.Manpage.xref list ->
?man:Cmdliner.Manpage.block list ->
?envs:env list ->
?doc:string ->
?version:string option ->
?name:string ->
(unit -> 'b) ->
'b command
Command maker.
val term : 'a command -> 'a Cmdliner.Term.t * Cmdliner.Term.info
term cmd
returns the Cmdliner
terms and info needed to use Cmdliner
. This ensures some compatiblity with Cmdliner
if defining a legacy Cmdliner
command term.
val run : 'a command -> 'a
run cmd
parses the command line according to the cmd
specification and returns the result of the underlying function.
val bool : bool conv
Converters
The following converters are inherited from Cmdliner
.
val char : char conv
val int : int conv
val nativeint : nativeint conv
val int32 : int32 conv
val int64 : int64 conv
val float : float conv
val string : string conv
val enum : (string * 'a) list -> 'a conv
val file : string conv
val dir : string conv
val non_dir_file : string conv
class virtual 'r cli : object ... end
The Object-Oriented CLI definition