package minicli

  1. Overview
  2. Docs
Exceptions
exception Not_an_int of string
exception Not_a_string of string
exception Not_a_float of string
exception Not_a_bool of string
exception No_param_for_option of string
exception More_than_once of string
exception Option_is_mandatory of string
exception Duplicate_in_specification of string
Initialization
val init : unit -> int * string list

Call init before using any of the other funtions (unless you really know what you are doing). let argc, args = CLI.init () in ... will compute argc and transform Sys.argv into the string list args.

Parse mandatory options
val get_int : string list -> string list -> int

read a mandatory int from the command line

val get_string : string list -> string list -> string

read a mandatory string from the command line

val get_float : string list -> string list -> float

read a mandatory float from the command line

val get_bool : string list -> string list -> bool

undocumented

val get_set_bool : string list -> string list -> bool

return true if flag was present on the command line, false otherwise

val get_reset_bool : string list -> string list -> bool

return false if flag was present on the command line, true otherwise

Parse optional options
val get_int_opt : string list -> string list -> int option

read an optional int from the command line

val get_string_opt : string list -> string list -> string option

read an optional string from the command line

val get_float_opt : string list -> string list -> float option

read an optional float from the command line

val get_bool_opt : string list -> string list -> bool option

undocumented

Parse optional options with a default value
val get_int_def : string list -> string list -> int -> int

read an optional int from the command line, or use the provided default if option was not seen on the command line

val get_string_def : string list -> string list -> string -> string

read an optional string from the command line, or use the provided default if option was not seen on the command line

val get_float_def : string list -> string list -> float -> float

read an optional float from the command line, or use the provided default if option was not seen on the command line

val get_bool_def : string list -> string list -> bool -> bool

undocumented

OCaml

Innovation. Community. Security.