https://github.com/shnewto/lilac
OCaml library for getting the value of any field in a YAML file as a string.
https://github.com/shnewto/lilac
bisect-ppx cmdliner codecov dune lilac mit ocaml ounit yaml yaml-unix
Last synced: about 1 month ago
JSON representation
OCaml library for getting the value of any field in a YAML file as a string.
- Host: GitHub
- URL: https://github.com/shnewto/lilac
- Owner: shnewto
- License: mit
- Created: 2021-01-26T02:58:27.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T01:31:30.000Z (over 3 years ago)
- Last Synced: 2026-04-11T15:36:23.350Z (about 2 months ago)
- Topics: bisect-ppx, cmdliner, codecov, dune, lilac, mit, ocaml, ounit, yaml, yaml-unix
- Language: OCaml
- Homepage:
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[](https://github.com/shnewto/lilac/actions)
[](https://codecov.io/gh/shnewto/lilac)
# lilac
lilac is a simple library for getting the value of any field in a YAML file as a string.
## Summary
Take this example yaml:
```yaml
lilac-params:
source:
url: "https://ttaw.dev"
user: "lilac+source@ttaw.dev"
dest:
url: "https://walkandtalk.dev"
user: "lilac+dest@walkandtalk.dev"
```
To get the value `"lilac+source@ttaw.dev"`, you'd specify the path `lilac-params.source.user`.
Here's an example of how you might do that in code with the yaml used in this project's `test/res` directory:
```ocaml
let yaml = yaml_from_fpath "test/res/config.yaml" in
yaml_value_str ~path:"lilac-params.source.user" yaml
|> Option.value ~default:"Oops! It wasn't there."
```
### lilacbin
The `lilacbin` app in this repo's `bin/` is really just used for debugging for now. It does have some niceties like a `--help` flag, but if there's something you're interested in it doing beyond debugging, let me know! Raising an issue is my preferred channel for that kinda thing.
## Dependencies
I'll start with the basics for macOS because putting this project together required I learn them too. I hope they'll
serve as at least some direction for other operating systems but if you notice something important I've missed,
please create an issue :heart:
First you'll need `opam` and `ocaml`.
For macOS:
- `brew install opam`
- `brew install ocaml`
For anything else, the opam installation docs live [here](https://opam.ocaml.org/doc/Install.html),
and the ocaml intallation docs live [here](https://ocaml.org/docs/install.html).
Once OCaml and opam are installed, run `opam init` from the terminal to get the environment sorted. I chose to
let it modify my terminal's rc file (`.zshrc`) so I wouldn't have to think about it again, but that's up to you :)
## Installing
If you just want to install lilac as a library and use it in your application, you can run `opam install lilac`.
Otherwise, see the Developing section below.
## Developing
## Dev dependencies
For local development, I'll recommend not installing with opam beforehand. Once you've cloned the repo and have navigated into its directory, you'll want to run these commands, in this order:
- `opam pin .`
- `opam install . --deps-only --with-test`
## Building
`make`
## Running the tests
`make test`
## Checking code coverage
`make coverage`
## Running lilac bin for stdout debugging / validation
`make run args='-i '`
For example `make run args='-i test/res/config.yaml'`