module Arg = struct ... end
Types | ||||||||||||||||||||||
spec |
|
Exceptions | |
Bad |
of string Functions in spec or anonfun can raise Arg.Bad with an error
message to reject invalid arguments. |
Simple values | |
current |
int Pervasives.ref Position (in Sys.argv ) of the argument being processed. You can
change this value, e.g. to force Arg.parse to skip some arguments. |
Functions |
parse
: keywords:(string * spec * string) list -> |
Arg.parse speclist anonfun usage_msg
parses the command line.
speclist
is a list of triples (key, spec, doc)
.
key
is the option keyword, it must start with a '-'
character.
spec
gives the option type and the function to call when this option
is found on the command line.
doc
is a one-line description of this option.
anonfun
is called on anonymous arguments.
The functions in spec
and anonfun
are called in the same order
as their arguments appear on the command line.Arg.parse
exits the program, after printing
an error message as follows:usage_msg
doc
string.-
, include for example ("-", String anonfun, doc)
in speclist
.parse
recognizes a unit option -help
, which will
display usage_msg
and the list of options, and exit the program.
You can override this behaviour by specifying your own -help
option in speclist
.
usage
: keywords:(string * spec * string) list -> errmsg:string -> unit |
Arg.usage speclist usage_msg
prints an error message including
the list of valid options. This is the same message that
Arg.parse
prints in case of error.
speclist
and usage_msg
are the same as for Arg.parse
.