The zig-bareini project is in a very-alpha stage and provides Zig library and a CLI tool.
“bareini” is a simple INI dialect aimed at readability and ease of maintenance. More in the README but in short:
-
Easy to read and write by humans. (Comments welcome!)
-
Encourages flat, section/key/value structure.
-
Can embed verbatim text without loss of readability and maintainability.
-
No quoting rules: everything is a prefixed string.
-
No semantics in the format: everything is a list of strings; any semantics and validation should happen in the application (with help of the API).
Quick example:
[zsf]
name = Zig Software Foundation
address = Zig Software Foundation
address = 1632 1st Ave #21385
address = New York, NY 10028
[fun]
block |= this
block |= will
block |= stay
block |= afloat
# comments are done with hash sign
Example of the Zig API is in the main README but to get the gist of it I’ll show the CLI:
@nauron:~$ bareini -P example.ini # show section/key names
zsf name
zsf address
fun block
@nauron:~$ bareini zsf address example.ini # read a section/key
Zig Software Foundation
1632 1st Ave #21385
New York, NY 10028
@nauron:~$ bareini fun block example.ini # indented blocks are supported!
this
will
stay
afloat
@nauron:~$ bareini -1 zsf address example.ini # insist on key being singleton
value was found multiple times: [work].address:
.. in example.ini, at line 4, column 15
.. in example.ini, at line 5, column 15
@nauron:~!3!$
A bit of history; I’ve been actually using an older variant of this INI dialect (under the name of “inigrep”) for many years for my hobby and work projects, most of them in Bash and Python. When starting to learn Zig I already wrote library and CLI as well (and some custom dev utils using it) but by design the old “inigrep” variant had too many footguns to be usable to anyone else.
So bareini is basically re-vamp of the same idea, just with as many footguns removed as possible.
I’d be happy to get some feedback, on the project (it’s still a moving target) but of course, mainly the Zig coding part!