filipegoncalves / rust-config

Configuration file library in Rust similar to C/C++'s libconfig
MIT License
20 stars 10 forks source link

Allow comma and space delimited values #7

Closed scowcron closed 8 years ago

scowcron commented 9 years ago

According to the libconfig grammar, comma and space are valid separators for settings as well as semicolons. Allow them.

setting = name (":" | "=") value (";" | "," | empty)

filipegoncalves commented 9 years ago

Thanks for your contribution.

The crate's documentation (http://filipegoncalves.github.io/rust-config/config/) should be the official source for the grammar; in particular, the entry that describes settings is:

setting -> __ name __ (":"|"=") __ value __ ";" __

Where __ is any number of blanks or block comments. It explicitly shows that settings should always be terminated by ;.

Could you please elaborate on the rationale behind these changes? Is there a specific use case or situation where you find this beneficial?

scowcron commented 9 years ago

I have a few configuration files I share between programs. They're all formatted without any semicolons to speak of, just separated by newlines.

This is my first foray into rust, but I thought I'd bring them with, and saw the libconfig style library and thought it was a done deal. Unfortunately the built-in error reporting still needs some work and I couldn't find any documentation for the crate (your page returns a 404), so I was left to the source. This patch is where I landed.

It would be easy enough to simply add semicolons to my configurations since i haven't distributed any of the programs that use them and that would make my files compatible with both libraries. However, I chose to omit the semicolons for aesthetic reasons, and my preference would be not to have to add them.

filipegoncalves commented 9 years ago

The documentation page is showing error 404? It works here. Try the alternative: http://codinghighway.com/rust-config/config/

Anyway, it looks good, I just think we could improve the examples that you changed (and the tests).

And yes, error reporting definitely needs some work (contributions welcome!), I just haven't had the time to get around it yet.

scowcron commented 9 years ago

The redirect from github.io worked fine, but the documentation is still showing a 404 for me.

I updated the tests a bit, but there are a lot of ways to make parsing fail. NO SPACE was misleading, I agree. I instead opted to give it a bad boolean value (NOPE). If you'd prefer to see something else there, I'm happy to oblige.