Psi
Ψ, written Psi where a name has to be ASCII, is cfg's own configuration format. It is read by a parser written for
cfg, so it keeps what other formats lose on the way: a value is exactly the text written, a tag is there only when
the author wrote one, and every error points at the source, line and column it is about. It takes from HOCON what makes
a configuration easy to compose — merging, substitutions, includes — and gives every one of its rules a single
spelling; YAML and HOCON files can be imported into it. Why it exists at all is Why cfg.
Sources are files named .psi, .ψ or .Ψ, in UTF-8.
A first source
// a service
server:
host: localhost
port: 8080
pool.max: 16
tags: [web, api]
loads as
server:
host: localhost
port: 8080
pool:
max: 16
tags:
- web
- api
What a source loads as is shown here, and on every page after this one, written back as Psi: the same tree, every value a string, written with indentation.
Writing Psi
- Syntax — fields, keys and values, blocks, comments and tags; indentation; text over several lines.
- Merging — what a key written twice gives, and how sources combine.
- Substitutions — referring to another part of the tree, injecting its fields or elements, and formatting it as text.
- Directives — values set at launch,
#propand#env; including other sources; importing YAML and HOCON. - Errors and limits — what a load reports, and how far it goes.
- Caveats — what is easy to get wrong.
- Psi, YAML and HOCON — what is written differently, for a reader who knows either.
From a program
libraryDependencies += "io.h8" %% "cfg-psi" % "0.6.0"