module OptParser:This module contains the option parser itself.sig
..end
It provides functions to create, populate and use option parsers to
parse command line arguments.
exception Option_conflict of string
Option_conflic 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.type
t
type
group
val make : ?usage:string ->
?description:string ->
?version:string ->
?suppress_usage:bool ->
?suppress_help:bool ->
?prog:string ->
?formatter:OptParse.Formatter.t -> unit -> t
usage
: Usage message. The default is a reasonable usage
message for most programs. Any occurrence of the substring
"%prog"
in usage
is replaced with the name of the program
(see prog
).version
: Version string. If set, a '--version' option is
automatically added. When encountered on the command line it
causes version
to be printed to the standard output and the
program to exit.suppress_usage
: Suppress the usage message if set.suppress_help
: Suppress the 'help' option which is
otherwise added by default.prog
: Program name. The default is the base name of the
executable.val add : t ->
?group:group ->
?help:string ->
?hide:bool ->
?short_name:char ->
?short_names:char list ->
?long_name:string -> ?long_names:string list -> 'a OptParse.Opt.t -> unit
Option_conflict
if the short name(s) or long name(s)
have alread been used for some other option.help
: Short help message describing the option (for the usage message).hide
: If true, hide the option from the usage
message. This can be used to implement "secret" options which
are not shown, but work just the same as regular options in all
other respects.short_name
: is the name for the short form of the option
(e.g. 'x'
means that the option is invoked with -x
on the
command line).short_names
: is a list of names for the short form of the
option (see short_name
).long_name
: is the name for the long form of the option
(e.g. "xyzzy"
means that the option is invoked with --xyzzy
on the command line).long_names
: is a list of names for the long form of the
option (see long_name
).val add_group : t ->
?parent:group ->
?description:string -> string -> group
parent
: is the parent group (if any).description
: is a description of the group.val error : t ->
?chn:Pervasives.out_channel -> ?status:int -> string -> unit
chn
(default is
Pervasives.stderr
) and the program exits with exit status
status
(default is 1).val usage : t -> ?chn:Pervasives.out_channel -> unit -> unit
chn
(default is
Pervasives.stdout
) and return.val parse : t ->
?first:int -> ?last:int -> string array -> string list
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
Sys.argv
.