Module BatArg


module BatArg: sig .. end
Parsing of command line arguments.

This module provides a general mechanism for extracting options and arguments from the command line to the program.

Syntax of command lines: A keyword is a character string starting with a -. An option is a keyword alone or followed by an argument. The types of keywords are: Unit, Bool, Set, Clear, String, Set_string, Int, Set_int, Float, Set_float, Tuple, Symbol, and Rest. Unit, Set and Clear keywords take no argument. A Rest keyword takes the remaining of the command line as arguments. Every other keyword takes the following word on the command line as argument. Arguments not preceded by a keyword are called anonymous arguments.

Examples (cmd is assumed to be the command name):

This module extends Stdlib's Arg module, go there for documentation on the rest of the functions and types.
Author(s): Damien Doligez (Base module), David Teller

type command 
The type describing both the name, documentation and behavior associated with a keyword.
val command : ?doc:string -> string -> Arg.spec -> command
Construct a new command, i.e. the specification of a keyword, an associated behavior and optionally a usage documentation.
doc : A string which will be displayed to the user in case of parsing error, and which should explain both the behavior and the syntax of this keyword. If left unspecified, no documentation is printed.
val handle : ?usage:string -> command list -> string list
Arg.handle commands parses the command-line and applies the specifications of commands and returns the list of anonymous arguments.

In case of error, the program exits and displays the usage message, if specified, and the documentation of command.

usage : An optional string which will be displayed to the user in case of parsing error. Typically, this string should contain the name and version of the program. If left unspecified, no usage string is displayed in case of error.