rusty-yaml

Crates.iorusty-yaml
lib.rsrusty-yaml
version0.4.3
sourcesrc
created_at2019-06-05 19:16:24.875068
updated_at2019-06-19 18:28:19.06575
descriptionA rust library to parse yaml files
homepage
repository
max_upload_size
id139213
size10,561
adam mcdaniel (adam-mcdaniel)

documentation

README

rusty-yaml

A rust library to parse yaml files.

Usage

Copy and paste the following into your Cargo.toml.

[dependencies]
rusty-yaml="0.1"

Examples

use rusty_yaml::Yaml;

fn main() {
    let yaml_reader = Yaml::from(
        "
builders:
    clang-format:
        worker: asgard-worker
        script:
            - ls

    build:
        worker: asgard-worker
        script:
            - mkdir build
            - cd build
            - cmake ..
            - make -j
            - ctest -j 4
",
    );

    println!(
        "section names: {:?}",
        yaml_reader
            .get_section("builders")
            .get_section("build")
            .get_section_names()
    );


    for section in yaml_reader.get_section("builders") {
        println!("```{}```", section);
    }


    println!("has builders: {}", yaml_reader.has_section("builders"));


    for section in yaml_reader.get_section("builders") {
        println!("Name: {}", section.get_name());
        for command in section.get_section("script") {
            println!("command: '{}'", command);
        }
    }
}
Commit count: 0

cargo fmt