Search code examples
configuration-filesaugeas

Parsing a simple libconfuse file with Augeas


I'm using libconfuse for my program's configuration files, and that's working nicely. Now I'm interested to parse the configuration files using Augeas. I found a mailing list post which says that there's no generic Augeas lens for libconfuse files, because it's a "context-free file format" (in essence, it allows infinite nesting).

My program's configuration files are quite simple, with just one level of sections containing configuration parameters. E.g.:

serial {
    serial-device = "/dev/ttyUSB0"
    baudrate = 115200
}

server-socket {
    host = "localhost"
    port = 12345
}

What would be involved in writing a generic Augeas lens for this simple variety of libconfuse configuration file? Are there any examples around? What would be the most straight-forward way to handle this?


Solution

  • The post you're referring to is from 2008. Augeas has since been able to parse recursive configuration files, using the rec keyword. See for example lvm.aug, which is quite similar to what you're trying to achieve.