Module Flags

module Flags: sig .. end
Quick and dirty argument processing. For full featured argument processing, use Arg, but if all you need is something very simple, Flags might do.

exception Argument_missing of string
Raised by methods Flags.lookup.string and when the requested argument isn't present.
class type lookup = object .. end
The argument parser Flags.go returns an object for querying its results.
val go : ?argv:string array -> ?usage:string -> string -> lookup
Flags.go spec parses the command-line arguments according to spec and returns a lookup object. If ?argv is given, it uses that rather than Sys.argv; if ?usage is given, it uses that as the sample command in the usage message.

The spec argument is a stylized sequence of arguments:

Single-hyphen arguments consist of one alphabetic character, while long (double-hyphen) arguments start with an alphabetic character followed by an arbitrary number of alphanumerics.

For example, we might use "-q -v -b <Before:int> -a <After:int> --baz <Baz>" to specify a program that takes boolean flags "-q" and "-v", integer arguments "-b" and "-a", and a string argument "--baz". If we pass this string to Flags.go and it returns an object lookup, we may then query lookup, for example: