From f82ca02c15b675ba889143aa7f7cd3c69e3f1810 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Fri, 3 Feb 2017 22:02:48 -0700 Subject: Add support for YAML --- examples/file-yaml/Cargo.toml | 6 ++++++ examples/file-yaml/Settings.yaml | 3 +++ examples/file-yaml/src/main.rs | 10 ++++++++++ 3 files changed, 19 insertions(+) create mode 100644 examples/file-yaml/Cargo.toml create mode 100644 examples/file-yaml/Settings.yaml create mode 100644 examples/file-yaml/src/main.rs (limited to 'examples') diff --git a/examples/file-yaml/Cargo.toml b/examples/file-yaml/Cargo.toml new file mode 100644 index 0000000..70176b1 --- /dev/null +++ b/examples/file-yaml/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "file-yaml" +version = "0.1.0" + +[dependencies] +config = { path = "../..", default-features = false, features = ["yaml"] } diff --git a/examples/file-yaml/Settings.yaml b/examples/file-yaml/Settings.yaml new file mode 100644 index 0000000..d92f6ad --- /dev/null +++ b/examples/file-yaml/Settings.yaml @@ -0,0 +1,3 @@ +debug: false +pi: 3.14159 +weight: 150 diff --git a/examples/file-yaml/src/main.rs b/examples/file-yaml/src/main.rs new file mode 100644 index 0000000..cd3286f --- /dev/null +++ b/examples/file-yaml/src/main.rs @@ -0,0 +1,10 @@ +extern crate config; + +fn main() { + // Read configuration from "Settings.yaml" + config::merge(config::File::new("Settings", config::FileFormat::Yaml)).unwrap(); + + println!("debug = {:?}", config::get("debug")); + println!("pi = {:?}", config::get("pi")); + println!("weight = {:?}", config::get("weight")); +} -- cgit v1.2.3