scfg-rs

A rust library for parsing [scfg] files. Scfg is a simple line oriented configuration file format. Every line may contain at most one directive per line. A directive consists of a name, followed by optional parameters separated by whitespace followed by an optional child block, delimited by { and }. Whitespace at the beginning of lines is insignificant. Lines beginning with # are comments and are ignored.

Examples

```rust use scfg::Scfg; // an scfg document static SCFG_DOC: &str = r#"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"
}

}"#; let doc = SCFG_DOC.parse::().expect("invalid document");

// the above document can also be created with this builder style api let mut scfg = Scfg::new(); let train = scfg .add("train") .appendparam("Shinkansen") .getorcreatechild(); let e5 = train.add("model").appendparam("E5").getorcreatechild(); e5.add("max-speed").appendparam("320km/h"); e5.add("weight").appendparam("453.5t"); e5.add("lines-served") .appendparam("Tōhoku") .appendparam("Hokkaido"); let e7 = train.add("model").appendparam("E7").getorcreatechild(); e7.add("max-speed").appendparam("275km/h"); e7.add("weight").appendparam("540t"); e7.add("lines-served") .appendparam("Hokuriku") .appendparam("Jōetsu");

assert_eq!(doc, scfg); ```

Contributing

Please send patches to the [mailing list]

LICENSE

MIT OR Apache-2.0