config-parser 0.1.2

A simple parser for block based configuration files
Documentation
  • Coverage
  • 23.26%
    10 out of 43 items documented0 out of 24 items with examples
  • Size
  • Source code size: 24.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.17 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Documentation
  • Kilobyte22/config-parser
    9 0 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Kilobyte22

A parser for configuration files.

Syntax

The syntax is similar to the config of nginx and pulseaudio.

Here an example how an irc bot might be configured

# Connect to freenode
server freenode {
    connect irc.freenode.net 6697 tls;
    nick BleghBot blegh "I am BleghBot owned by MyAdmin";

    channel "#freenode";
    channel "#secret" mypassword;
    
    user MyAdmin {
        allow all;
    }

    user ShittySpammer {
        deny all;
    }
}

API

The API is pretty simple:

extern crate config_parser;

let mut file = File::open("config.cfg").unwrap();

let cfg = config_parser::parse_file(file).unwrap();

for server in cfg.matches("server") {
    let s = Server::new(server.get(0));

    for channel in server.matches("channel") {
        s.add_channel(channel.get(0), channel.get_opt(1));
    }
}