B0_meta.Key
Keys.
val make :
?doc:string ->
?default:'a ->
string ->
pp_value:'a B0_std.Fmt.t ->
'a key
make name ~default ~pp_value ~doc
is a new metadata key with:
name
the name used for UI interaction. It should be globally unique, the module automatically renames it if that happens not to be the case.default
is an optional default value for the key when undefined in a dictionary.pp_value
is used to format the key values for end-users.doc
is a documentation string for the key.val make_tag : ?doc:string -> string -> bool key
make_tag ~doc name
is a new tag key named name
. Denote booleans that are false when absent (that's their default value). In effect this is strictly equivalent to:
make ?doc name ~default:false ~pp_value:Fmt.bool
val name : 'a key -> string
name k
is k
's name.
val default : 'a key -> 'a option
default k
is a default value for the key (if any).
val get_default : 'a key -> 'a
get_default k
is the default value of k
. Raises Invalid_argument
if k
has no default.
val doc : 'a key -> string
doc k
is k
's documentation string.
val pp_value : 'a key -> 'a B0_std.Fmt.t
pp k
is k
's value formatter.
val pp_name : 'a key B0_std.Fmt.t
pp_name k
formats k
's name with pp_name_str
.
val pp_name_str : string B0_std.Fmt.t
pp_name_str
formats a key name.
val pp : t B0_std.Fmt.t
pp
formats the key name with pp_name_str
For UI purposes a map from key names to existential keys is maintained by the module.
val find : string -> t option
find n
is the key named n
(if any).
val get : string -> t
get n
is the key named n
. Raises Invalid_argument
if there is no such key.
get_or_suggest n
is the key named n
or or a (possibly empty) list of suggested values whose name could match n
.
val get_or_hint : string -> (t, string) Stdlib.result
get_or_hint n
is the key named n
or an error message that indicates that n
could not be found with suggested names.
val list : unit -> t list
val fold : (t -> 'a -> 'a) -> 'a -> 'a
val get_list_or_hint :
all_if_empty:bool ->
string list ->
(t list, string) Stdlib.result