Module Parseopt

module Parseopt: sig .. end
Specifies how key names are built from fieldnames

type keyspec =
| Short (*From fieldname foobar, generate key -f*)
| Long1 (*From fieldname foobar, generate key -foobar*)
| Long2 (*From fieldname foobar, generate key --foobar*)

type parsetype =
| Gnu (*Gnu/UNIX-style; multiple option keys which do not require an argument can be collapsed together (-g -x -f can be given as -gxf). Also, option arguments don't need to be preceded by a space if the key is a single character (e.g. -z 34 can be given as -z34).*)
| Caml (*OCaml-style; each key and each argument must be separated by whitespace.*)
Specifies how options are tokenized

These functions are provided as handy actions for no-argument keys
val set : 'a -> bool
Set a boolean field to true
val clear : 'a -> bool
Set a boolean field to false
val store : 'a -> 'b -> 'a
Store a value in a field

type 'a option_parameters = {
   default : 'a; (*The default values for all options*)
   specs : (string * string list * string * string option * 'a action) list; (*For internal usage*)
   to_string : 'a -> string; (*= A string representation of the arguments*)
   keyspecs : keyspec list; (*A list of Parseopt.keyspecs indicating how to form keys from the fieldname. The default is Short;Long1*)
   usage_prefix : string;
   usage_suffix : string;
   parsetype : parsetype; (*See Parseopt.parsetype; the default is Caml*)
   is_option : string -> bool; (*This function is used to tell whether a token on the command-line is or is not an option. You might use this if you wanted options to start with a different character.*)
   dashdash : bool; (*If this variable is true (the default), the sequence "--" on the command-line terminates option processing. All subsequent tokens are considered to be arguments, even if they start with "-".*)
   helpkeys : string list; (*The set of keys which generates the help message (help ()). The default is -h, -help, --help, -?*)
   helpfieldwidths : int * int * int; (*The widths of the key-list, argument, and message columns in the output displayed by help ().*)
   keepgoing : bool; (*If true, then option keys can be interspersed on the command-line with anonymous arguments. If false, option processing terminates with the first token not marked as an option (beginning with -). The default is true; set to false to allow processing subcommands.*)
Specifies how options should be parsed

type 'a action_parameters = {
   options : 'a; (*The value of the options record before this option*)
   args : string list; (*The remaining tokens on the command line*)
   option_parameters : 'a option_parameters; (*The option_parameters value*)
This type is passed to Action, Conversion, or Handler functions

type 'a action =
| Action of ('a action_parameters -> 'a)
| Conversion of ('a action_parameters -> string -> 'a)
| Handler of ('a action_parameters -> 'a * string list)
Internal type used by the syntax extension; like Arg.spec
val set' : ('a -> 'a) -> 'a action_parameters -> 'a * string list
If you want an option to be able to affect other elements of the option structure, you can specify handler = set' (fun o -> {o with ...})

For example, you could have multiple options that set or clear a flag.

val conversion' : ('a -> string -> 'a) -> 'a action_parameters -> 'a * string list
If you want an option to be able to affect other elements of the option structure, based on an argument, you can specify handler = conversion' (fun o s -> {o with ...})

The difference between set' and conversion' is that a conversion' option takes an argument.

val option_defaults : unit option_parameters
Default values for option parameters

Exceptions that may be raised during the parsing process
exception MissingArgument of string
exception UnknownOption of string
exception ConversionFailure of string * string * string
val help : 'a option_parameters -> unit
Print a help message containing all options
val usage : 'a option_parameters -> unit
Print a usage message
val parse : 'a option_parameters -> string list -> 'a * string list
Parse an arbitrary list of strings as if it were command-line arguments
val parse_argv : 'a option_parameters -> 'a * string list
Parse Sys.argv

$Revision: 1.6 $