Module B0.Conf

module Conf: sig .. end
Build configuration.

Typed, persistable, key-value bindings to configure builds. See the manual for a conceptual introduction.

TODO. It's unclear whether this is only build configuration we might use it for deployement configuration aswell.



Configurations


include B0.Hmap.MAP
Configurations.

Persistence


val load : B0.Fpath.t -> (t * decode_error list) B0.result
load file loads a configuration from file.
val save : t -> B0.Fpath.t -> encode_error list B0.result
save c file saves configuration c to file.

Key value


type 'a value 
The type for key value of type 'a.
val const : 'a -> 'a value
const v is the value v.
val discover : ?store:bool ->
(B0.Env.t -> B0.Env.build_aim -> 'a key -> t -> 'a B0.result) ->
'a value
discover ~store f is the value f k c with c the configuration in which the value must be defined and k the actual key. If store is true (default) and the result of the invocation is not an error the result of the key discovery will be persisted for future runs. If store is false, f is always executed on lookup unless the key is explicitely defined in c.

FIXME.


val value : B0.Env.t ->
B0.Env.build_aim -> 'a key -> t -> 'a value -> 'a B0.result
value k c v determines the value of v with respect to k and c (for B0.Conf.discovered).
val value_const : 'a value -> 'a option
value_const d is d's constant value (if any).
val value_store : 'a value -> bool
value_store d is true if the discovered value should be stored. This is false on B0.Conf.const.
val pp_value : 'a B0.Fmt.t -> 'a value B0.Fmt.t
pp_value k ppf v prints v's constant value or the fact that it is discovered.

Key groups


module Group: sig .. end
Key groups.

Keys


module Key: sig .. end
Configuration keys.
val key : ?loc:B0.Def.loc ->
?doc:string ->
?group:Group.t ->
string -> 'a B0.Conv.t -> default:'a value -> 'a key
key n conv ~default ~group ~doc is a configuration key with unique name n whose value is converted using conv. If the key is undefined when looked up in a configuration it is determined according to default. If group is provided the key belongs to the given group (defaults to B0.Conf.Group.none).

Warning. Keys need to be defined at toplevel and are subject to namespacing, see details.

val get_default : B0.Env.t -> B0.Env.build_aim -> 'a key -> t -> 'a B0.result
get_default k c is k's default value in c.
val get_effective : B0.Env.t ->
B0.Env.build_aim ->
'a key -> t -> ([ `Conf | `Default | `Env ] * 'a) B0.result
get_effective env k c gets the effective value of key k in environment env and configuration c. This is the first value determined by the following steps:
  1. If B0_C_$KEY is defined in env, decode a value using k's converter. $KEY is Key.name k uppercased and with '.' substituted by '_'.
  2. If k is defined in c, use its value.
  3. Otherwise, use k's default value in c.
An error is returned if decoding the environment variable fails or if the default value discovery errors.
val keys : t -> Key.t list
keys c are the keys defined in c.

Presets


module Preset: sig .. end
Configuration presets.
val of_preset : B0.Env.t ->
B0.Env.build_aim -> Preset.t -> t * Preset.def_error list
of_preset p is Preset.add p empty.