Skip to content

Instantly share code, notes, and snippets.

@rogeruiz
Last active June 4, 2021 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeruiz/200437c7a6b35afcb8000794e0d3f0f4 to your computer and use it in GitHub Desktop.
Save rogeruiz/200437c7a6b35afcb8000794e0d3f0f4 to your computer and use it in GitHub Desktop.
Testing config-rs and shellexpand to read from a YAML file.
[package]
name = "test-config-with-shellexpand"
version = "0.1.0"
edition = "2018"
[dependencies]
config = "0.11.0"
shellexpand = "2.1.0"
value1: test value for config-rs yaml
value2: another test value yaml
extern crate shellexpand;
use config::*;
fn main() {
let config_path = shellexpand::tilde("~/.config/example/e.yaml").to_string();
let mut settings = Config::default();
settings.merge(File::with_name(&config_path)).unwrap();
let value1 = settings.get_string("value1").unwrap();
println!("\n{:?} \n\n-----------",
value1);
let value2 = settings.get_string("value2").unwrap();
println!("\n{:?} \n\n-----------",
value2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment