package oenv
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=0f9059e396f2ac8aeb8e9fde194a3708811d825c9f9df12d57aeb2d5b01cda1f
sha512=976de11d938b2726de50bcec3d83513decf6f59545d789f1d5065c7a612510f080729e3ade21910ea5547ff085b2f47e81aa41cfb507c9a9c4a02d103c0801f3
Description
oenv is a library for reading environment variables in a composable way, with support for default values, required variables, custom types, and logging via logs.
Added to opam-repository:
README
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 tCustom 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_stringSee ./examples and reference for more details.
Dependencies (4)
- ppx_deriving
- logs
-
dune
>= "3.18" -
ocaml
>= "5.2"
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building oenv with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.1.0 (this version) | n/a | n/a | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure