package oenv
A composable environment variable reader
Install
dune-project
Dependency
Authors
Maintainers
Sources
oenv-0.0.1.tbz
sha256=1037dc315ff97d67ff0f7891166e9a0bb9892bfb5cf4bd1a843f0faf4963a65d
sha512=55dd36d1035c916abf726980d2952328bb080471dba9cf00974cc3f828ef8fa6898e7793b76ac36c43c9a94ddf16b258e48f5cc07ec7bd2707ee6c459752a3b6
doc/README.html
Oenv
A composeable environment variable reader for OCaml
Example
let ( let* ) m k = Result.bind in
let* debug = Oenv.(bool "DEBUG" |> read) in
let* api_key = Oenv.(string "API_KEY" |> read) in
Printf.printf "settigns: debug: %b, api_key: %s\n" debug api_key;
Result.ok ()
Features
- Basic types: string, int, bool
- 2nd types: list, option
- Product
- Custom types
- Logs support
Product
Product
creates product reader.
type t =
{ name : string
; value : string option
}
let make name value = { name; value }
let t = Oenv.(Product.v make
+: string "NAME"
+: string "VALUE" |> option
|> close)
Oenv.read t
Custom types
Make custom type reader with custom
combinator.
type flag = A | B
let of_string = function
| "A" -> Ok A
| "B" -> Ok B
| other -> Error (`Parse ("flag", other))
let flag = Oenv.custom ~secret:false "FLAG" of_string
See ./examples and reference for more details.
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page