BatOptParse.OptParser
This module contains the option parser itself.
It provides functions to create, populate and use option parsers to parse command line arguments.
Option_conflict name
is raised by OptParse
.OptParser.add when two different options are added with identical names. Usually this doesn't need to be caught since this error is usually easily fixed permanently by removing/renaming the conflicting option names.
val make : ?usage:string -> ?description:string -> ?version:string ->
?suppress_usage:bool -> ?suppress_help:bool -> ?only_leading_opts:bool ->
?prog:string -> ?formatter:Formatter.t -> unit -> t
Creates a new option parser with the given options.
val add : t -> ?group:group -> ?help:string -> ?hide:bool -> ?short_name:char ->
?short_names:char list -> ?long_name:string -> ?long_names:string list -> 'a Opt.t -> unit
Add an option to the option parser.
Add a group to the option parser.
val error : t -> ?chn:out_channel -> ?status:int -> string -> unit
Display an error message and exit the program. The error message is printed to the channel chn
(default is Pervasives.stderr
) and the program exits with exit status status
(default is 1).
val usage : t -> ?chn:out_channel -> unit -> unit
Display the usage message to the channel chn
(default is Pervasives.stdout
) and return.
val parse : t -> ?first:int -> ?last:int -> string array -> string list
Parse arguments as if the arguments args.(first)
, args.(first+1)
, ..., args.(last)
had been given on the command line. By default first
is 0 and last
is the index of the last element of the array.
val parse_argv : t -> string list
Parse all the arguments in Sys.argv
.