A group of cps, that can be loaded and saved, or used to generate command line arguments.

The basic usage is to have only one group and one configuration file, but this mechanism allows to have more, for instance to have another smaller group for the options to pass on the command line.

method add : 'a cp -> unit

Adds a cp to the group. Note that the type 'a must be lost to allow cps of different types to belong to the same group.

  • raises Double_name

    if cp#get_name is already used.

method write : ?with_help:bool -> string -> unit

write filename saves all the cps into the configuration file filename.

method read : ?obsoletes:string -> ?no_default:bool -> ?on_type_error: (groupable_cp -> Raw.cp -> (out_channel -> unit) -> string -> in_channel -> unit) -> string -> unit

read filename reads filename and stores the values it specifies into the cps belonging to this group. The file is created (and not read) if it doesn't exists. In the default behaviour, no warning is issued. If not all cps are updated or if some values of filename aren't used.

If obsoletes is specified, then prints in this file all the values that are in filename but not in this group. Those cps are likely to be erroneous or obsolete. Opens this file only if there is something to write in it.

If no_default is true, then raises Missing_cp foo if the cp foo isn't defined in filename but belongs to this group.

on_type_error groupable_cp value output filename in_channel is called if the file doesn't give suitable value (string instead of int for instance, or a string not belonging to the expected enumeration) for the cp groupable_cp. value is the value read from the file, output is the argument of Config_file.Wrong_type, filename is the same argument as the one given to read, and in_channel refers to filename to allow a function to close it if needed. Default behaviour is to print an error message and call exit 1.

method read_string : ?obsoletes:string -> ?no_default:bool -> ?on_type_error: (groupable_cp -> Raw.cp -> (out_channel -> unit) -> string -> unit) -> string -> unit

read_string string reads the content of string and stores the values it specifies into the cps belonging to this group.

This method behaves just like read for the others aspects.

method command_line_args : section_separator:string -> (string * Arg.spec * string) list

Interface with module Arg.

  • parameter section_separator

    the string used to concatenate the name of a cp, to get the command line option name. "-" is a good default.

  • returns

    a list that can be used with Arg.parse and Arg.usage.