Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kilobyte22/config-parser
A simple config parser in rust
https://github.com/Kilobyte22/config-parser
Last synced: 9 days ago
JSON representation
A simple config parser in rust
- Host: GitHub
- URL: https://github.com/Kilobyte22/config-parser
- Owner: Kilobyte22
- Created: 2016-06-02T14:18:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-15T21:11:18.000Z (about 8 years ago)
- Last Synced: 2024-10-31T11:42:51.243Z (12 days ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:```rust
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));
}
}```