module Args:sig
..end
Parsing command line arguments in a functional way.
type
kind =
| |
Int |
|||
| |
Float |
|||
| |
String |
|||
| |
Set_true |
(* |
| *) |
| |
Set_false |
(* |
| *) |
| |
Custom of |
(* | the string after this constructor gives clue to the user about the expected type | *) |
| |
StringAcc |
(* | This command will accumulate the parameters when several ones are provided on the command line. | *) |
for non-Acc
kinds if an argument is given several times on the
command line the last one overwrites the previous ones
type
p =
| |
Default of |
| |
Defaults of |
| |
Required |
| |
Optional |
typespec =
string * p * kind * string
(command_line_argument, about_value, kind, help_msg)
typeargs =
string list
typically Sys.args
type
cmd
val parse : spec list -> args -> cmd
val usage : spec list -> unit
The string should be the same than the first element of
the spec
entry
val get_int : cmd -> string -> int
val get_float : cmd -> string -> float
val get_bool : cmd -> string -> bool
val get_string : cmd -> string -> string
val get_custom : (string -> 'a) -> cmd -> string -> 'a
val get_string_list : cmd -> string -> string list
Option
val get_int_opt : cmd -> string -> int option
val get_float_opt : cmd -> string -> float option
val get_bool_opt : cmd -> string -> bool option
val get_string_opt : cmd -> string -> string option
val get_custom_opt : (string -> 'a) -> cmd -> string -> 'a option