package minicli

  1. Overview
  2. Docs

Module Minicli.CLISource

Exceptions
Sourceexception Not_an_int of string
Sourceexception Not_a_string of string
Sourceexception Not_a_float of string
Sourceexception Not_a_bool of string
Sourceexception No_param_for_option of string
Sourceexception More_than_once of string
Sourceexception Option_is_mandatory of string
Sourceexception Duplicate_in_specification of string
Sourceexception Unused_options of string
Sourcetype args = string list

Sys.argv as a list

Sourcetype option_strings = string list

all accepted strings meaning the same option

Initialization
Sourceval init : unit -> int * args

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.

Finalization
Sourceval finalize : unit -> unit

You can (but you are not forced to) call finalize in case options parsing is finished. Meaning, the program will not try to process command line options anymore. finalize will enforce that there are no unused options left on the command line. In case there are some options left unused on the command line, finalize will raise an Unused_options exception listing them all.

Parse mandatory options
Sourceval get_int : option_strings -> args -> int

read a mandatory int from the command line

Sourceval get_char : option_strings -> args -> char

read a mandatory char from the command line

Sourceval get_string : option_strings -> args -> string

read a mandatory string from the command line

Sourceval get_float : option_strings -> args -> float

read a mandatory float from the command line

Sourceval get_bool : option_strings -> args -> bool

undocumented

Sourceval get_set_bool : option_strings -> args -> bool

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

Sourceval get_reset_bool : option_strings -> args -> bool

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

Parse optional options
Sourceval get_int_opt : option_strings -> args -> int option

read an optional int from the command line

Sourceval get_char_opt : option_strings -> args -> char option

read an optional char from the command line

Sourceval get_string_opt : option_strings -> args -> string option

read an optional string from the command line

Sourceval get_float_opt : option_strings -> args -> float option

read an optional float from the command line

Sourceval get_bool_opt : option_strings -> args -> bool option

undocumented

Parse optional options with a default value
Sourceval get_int_def : option_strings -> args -> int -> int

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

Sourceval get_string_def : option_strings -> args -> string -> string

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

Sourceval get_char_def : option_strings -> args -> char -> char

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

Sourceval get_float_def : option_strings -> args -> float -> float

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

Sourceval get_bool_def : option_strings -> args -> bool -> bool

undocumented

OCaml

Innovation. Community. Security.