scfg

Crates.ioscfg
lib.rsscfg
version
sourcesrc
created_at2020-10-21 22:11:47.233012
updated_at2024-10-28 16:07:40.359949
descriptionAn scfg parser
homepage
repositoryhttps://git.sr.ht/~cdv/scfg-rs
max_upload_size
id304003
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Christopher Vittal (chrisvittal)

documentation

README

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

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::<Scfg>().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")
    .append_param("Shinkansen")
    .get_or_create_child();
let e5 = train.add("model").append_param("E5").get_or_create_child();
e5.add("max-speed").append_param("320km/h");
e5.add("weight").append_param("453.5t");
e5.add("lines-served")
    .append_param("Tōhoku")
    .append_param("Hokkaido");
let e7 = train.add("model").append_param("E7").get_or_create_child();
e7.add("max-speed").append_param("275km/h");
e7.add("weight").append_param("540t");
e7.add("lines-served")
    .append_param("Hokuriku")
    .append_param("Jōetsu");

assert_eq!(doc, scfg);

Contributing

Please send patches to the mailing list

LICENSE

MIT OR Apache-2.0

Commit count: 0

cargo fmt