Module Conf.Bit

Configuration bits.

Bundles a cli interface and a configuration file lookup.

Note. For Cmdliner proper support we would likely hide it in Cmdliner terms and let them handle the merge logic. Though that poses a few problems with e.g. configuration error report/recovery. Another problem is the recursion between specifying the configuration file lookup on the cli itself while using it terms themselves. Also lazy absents.

Configuration bits

type 'a t

The type for configuration bits of type 'a.

val with_cli_arg : ?docs:string -> ?docv:string -> string -> doc:string -> absent:'a -> conf:'a B00_serialk_sexp.Sexpq.t -> arg:(Cmdliner.Arg.info -> 'a option Cmdliner.Arg.t) -> 'a t

with_cli_arg n ~doc ~docs ~docv ~absent ~conf ~arg is a configuration bit named by n.

  • arg is used to parse the bit from the cli using an option argument named n documented with doc in section docs and metavariable docv.
  • conf is used to lookup the bit value in a configuration dictionary with an optional key n.
  • absent is used as a default value.
val with_cli : string -> absent:'a -> conf:'a B00_serialk_sexp.Sexpq.t -> cli:'a option Cmdliner.Term.t -> 'a t

with_cli n ~absent ~conf ~cli is a configuration bit named by n

  • cli is used to get the bit from the cli.
  • conf is used to lookup the bit value in a configuration dictionary with an optional key n.
  • basent is used as a default value.
val cli : 'a t -> 'a option Cmdliner.Term.t

cli b is the command line interface for b.

val conf : 'a t -> 'a B00_serialk_sexp.Sexpq.t

conf b is the configuration key query for b. If the key is not found absent is returned.

val get : 'a t -> 'a option -> (B00_serialk_sexp.Sexp.t * B00_serialk_sexp.Sexpq.path) -> ('a, string) result

get b cli sexp gets the configuration bit from sexp if cli is None. If it's not in the configuration then absent is returned.

val append : 'a list t -> 'a list option -> (B00_serialk_sexp.Sexp.t * B00_serialk_sexp.Sexpq.path) -> ('a list, string) result

append b cli sexp gets the configuration bit from sexp and appends them to cli.