Inspired by this presentation
- Create a pure functional library to load configuration from different sources, like properties files, json, yaml or any other source.
- Allow to switch from sources without changing the program.
- Self documented.
- Type safe.
Now it supports properties and toml files.
[server]
host = "localhost"
port = 8080
record HostAndPort(String host, Integer port) { }
var readHostAndPort = PureCFG.map2(PureCFG.readString("host"), PureCFG.readInt("port"), HostAndPort::new);
var program = PureCFG.readConfig("server", readHostAndPort);
var config = program.unsafeRun(Source.fromToml("config.toml"));
assertEquals(new HostAndPort("localhost", 8080), config);
Distributed under MIT License