Module B0.Conf.Preset

module Preset: sig .. end
Configuration presets.

A configuration preset is a named set of key-value binding definitions. Presets allow users to quickly setup a given sub configuration.

Preset value definition

type conf = t 
val const : 'a -> 'a B0.Conf.value
const is B0.Conf.const.
val discover : ?store:bool ->
(B0.Env.t -> B0.Env.build_aim -> 'a key -> t -> 'a B0.result) ->
'a B0.Conf.value
discover is
type def 
The type for a preset value definition.
val def : ?doc:string -> 'a key -> 'a B0.Conf.value -> def
def k d is a preset element that sets k to definition d.

Note. The stored argument of is meaningless for presets, as the only way to use a preset's value is to add its bindings to a configuration.

val def_key : def -> B0.Conf.Key.t
def_key d is d's key.
val def_doc : def -> string
def_doc d is d's documentation string.
type binding = 
| B : 'a key * 'a B0.Conf.value -> binding
The type for preset key-value bindings.
val def_binding : def -> binding
def_binding d is d's key-value binding.


type t 
The type for configuration presets.
val v : ?loc:B0.Def.loc ->
?doc:string -> string -> def list -> t
v name ~doc defs is a preset with unique name n, key-value definitions defs an documented by doc.

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

include B0.Def.S
val defs : t -> def list
defs p are p's key-value definitions, sorted by key name.
val find_def : string -> t -> def option
find_def name finds a definition for a key named name.
val get_or_suggest_def : string ->
t -> (def, string list) Pervasives.result
get_or_suggest_def name is the definition for a key named name if it exists or a list of suggested key names that could match name.
val keys : t -> B0.Conf.Key.t list
keys p are the keys that are preset by p.

Apply and remove

type def_error = string * [ `Msg of string ] 
The type for preset definition errors, the failed key name and the error message.
val add : B0.Env.t ->
B0.Env.build_aim ->
t ->
conf -> conf * def_error list
add p c is (c', errs) where c' is c with the bindings of p added. If a preset value discovery functions the failed key name and error message is in erros and the binding is left unchanged.
val rem : t -> conf -> conf
rem_preset p c is c with no bindings for p's keys.