Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonivade/purecfg
Pure Functional Configuration Library
https://github.com/tonivade/purecfg
configuration experimental functional-programming java purefun
Last synced: 17 days ago
JSON representation
Pure Functional Configuration Library
- Host: GitHub
- URL: https://github.com/tonivade/purecfg
- Owner: tonivade
- License: mit
- Created: 2020-02-02T19:01:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-22T05:52:07.000Z (25 days ago)
- Last Synced: 2024-10-23T05:56:40.058Z (24 days ago)
- Topics: configuration, experimental, functional-programming, java, purefun
- Language: Java
- Size: 670 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PureCFG
Inspired by this [presentation](https://github.com/jdegoes/scalaworld-2015/blob/master/presentation.md)
## Objectives
- 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.
## Example
```toml
[server]
host = "localhost"
port = 8080
``````java
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);
```## License
Distributed under MIT License