module Configuration_files: sig
.. end
This module contains a simple implementation of application-wise configuration
files, implemented as shell scripts; configuration files are looked for (by
default) in "standard" places like /etc, the user's home directory and the
shell environment.
There is a priority:
- System-wise files in /etc
- User's files in ~
- The shell environment at application startup time.
This module contains a simple implementation of application-wise configuration
files, implemented as shell scripts; configuration files are looked for (by
default) in "standard" places like /etc, the user's home directory and the
shell environment.
There is a priority:
- System-wise files in /etc
- User's files in ~
- The shell environment at application startup time.
type 'a
alist = (string * 'a) list
An alist is just a list of pairs:
val output_of_environment : string list -> string
For each variable bound in the shell environment echo its name and its value,
one binding per line:
val output_of_file_name : string -> string list -> string
Evaluate the given file, then 'echo' each variable name and its value, one variable
per line:
val matrix_of_output : string -> string list list
Convert an output into a list of rows, where each row is a list of
strings: first the variable name, then the value, possibly made of several
tokens:
val variables_of_matrix : 'a list list -> 'a list
Extract only the variable names from the matrix, disregarding values:
val alist_of_matrix : ('a list -> 'b) -> 'a list list -> ('a * 'b) list
Turn a matrix into an alist mapping each variable name into a value; each
variable value (as a list of strings) is passed to the given function to
obtain the value which is bound in the returned environment. Variables for
which the given function fails are simply ignored:
val scalar_alist_of_matrix : (string -> 'a) -> string list list -> (string * 'a) list
Turn a matrix into an alist mapping each variable name into a value; each
variable value (as a single string, with token separated by a single space)
is passed to the given function to obtain the value which is bound in the
returned environment. Variables for which the given function fails are simply
ignored:
val list_alist_of_matrix : string list list -> (string * string list) list
Turn a matrix into an alist mapping each variable name into the list of
the tokens of its value:
val string_alist_of_matrix : string list list -> (string * string) list
Turn a matrix into an alist mapping each variable name into the string
containing its value (tokens concatenated into a string, separated by
single spaces):
val int_alist_of_matrix : string list list -> (string * int) list
Turn a matrix into an alist mapping each variable name with an integer
value into the integer. Non-integer-valued variables are ignored:
val float_alist_of_matrix : string list list -> (string * float) list
Turn a matrix into an alist mapping each variable name with an float
value into the float. Non-float-valued variables are ignored:
val bool_alist_of_matrix : string list list -> (string * bool) list
Turn a matrix into an alist mapping each variable name with an bool
value into the bool. Non-bool-valued variables are ignored:
val alists_of_output : string ->
'a ->
(string * string) list * (string * int) list * (string * float) list *
(string * bool) list * (string * string list) list
Turn a matrix into a "tuple of alists", which henceforth means
an alist of strings, an alist of ints, an alist of floats, an
alist of bools, and an alist of lists of strings; as usual, values
of the "wrong" type are ignored:
val alists_of_file : string ->
string list ->
(string * string) list * (string * int) list * (string * float) list *
(string * bool) list * (string * string list) list
Turn a *file* into a tuple of alists:
val merge_alists : 'a list * 'b list * 'c list * 'd list * 'e list ->
'a list * 'b list * 'c list * 'd list * 'e list ->
'a list * 'b list * 'c list * 'd list * 'e list
Merge the two given alist groups; the latest one takes precedence:
class configuration : ?software_name:string -> ?file_names:string list -> variables:string list -> ?read_environment:bool -> unit ->
object
.. end
Make a configuration object from a list of file name or a software name;
in the latter case the configuration files have "reasonable" default
names: