package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=1bcb27dfbd130eb057561196ef851649
sha512=2a56611b09a5f1cba6457539f8b6bc87a5f2a5454b36cdb39f6e0d6a5dac6db179aab1ba87c74dd49cc41df31a9a96feb349028ea41df7371ecb47f4d9dfafc4
doc/batteries.unthreaded/BatOptParse/OptParser/index.html
Module BatOptParse.OptParser
This module contains the option parser itself.
It provides functions to create, populate and use option parsers to parse command line arguments.
Exceptions
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.
Types
Option parser creation
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.
Output and error handling
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.
Option parsing
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
.