No big deal, but it might be of interest to some of you. For a project, I needed a configuration format that could represent hierarchies and was easy for humans to write.
I initially looked at KDL (there are two implementations for Nim, see https://github.com/Patitotective/kdl-nim (KDL 1.0) and https://github.com/greenm01/nimkdl (KDL 2.0), but found it too complex for my needs. Then, by chance, I stumbled upon Simon Ser's scfg project, which implements a simple, line-based language. There's also a Nim implementation for it (see https://codeberg.org/xoich/nim-scfg), but I haven't tried it. I wanted one file that I could simply drop into a project.
To cut a long story short, here is scfg-nim
Examples how scfg looks like:
server {
listen 80
server_name example.com www.example.com
location / {
root /var/www/html
index index.html index.htm
}
location = /robots.txt {
allow all
log_not_found off
access_log off
}
}
train "Shinkansen" {
model "E5" {
max-speed 320km/h
weight 453.5t
lines-served "Tōhoku" "Hokkaido"
}
model "E7" {
max-speed 275km/h
weight 540t
lines-served "Hokuriku" "Jōetsu"
}
}(Already you used some goofy syntax location = /robots.txt I cannot interpret reliably.)
You've probably never configured nginx before? ;)
The aforementioned examples are meaningless in themselves; it is up to the implementation to interpret them. scfg only recognizes directives with a name (string), optional parameters (each is a string), and optional children (directive).
The following example:
$x = 42
$found_answer = false
if $x == 42 {
$found_answer = true
}
is: