package lilac

  1. Overview
  2. Docs
Get the value of any field in a YAML file as a string

Install

Dune Dependency

Authors

Maintainers

Sources

0.1.1.tar.gz
md5=40e01c5ef4289477a523ae5a46d5c95d
sha512=1d991b6115ddddf3a314edce48f6130bb6ef2faa0ad204883de5ff7ad9e29c25d112ea7a59a82aa36b34217ce53b3258100061547ab6b6c9a01edd49ab49a4cb

Description

Tags

library lib lilac yaml

Published: 03 Feb 2021

README

README.md

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:

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:

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, so it's dependencies are tagged as test only requirements in the package manifest. 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, and the ocaml intallation docs live here.

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 <path to yaml file>'

For example make run args='-i test/res/config.yaml'

Dependencies (6)

  1. ocaml >= "4.10.0"
  2. dune >= "2.7.0"
  3. yaml >= "2.1.0"
  4. base >= "v0.9.0"
  5. stdio >= "v0.9.0"
  6. cmdliner >= "1.0.4"

Dev Dependencies (2)

  1. bisect_ppx dev & >= "2.5.0"
  2. ounit with-test

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.