From 194881ebf325f269891eb05c41c4bcf0baf3fed3 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Sat, 7 Sep 2019 14:38:49 -0400 Subject: config file done --- src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 4405674..1e7bd63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,22 @@ +use std::fs; + use serde::{Deserialize, Serialize}; +use serde_yaml; const VERS: &str = "v0.1"; const OUT_PATH: &str = "/var/www/htdocs/tilde.json"; +const CONF_PATH: &str = "instistats.yml"; #[derive(Debug, Deserialize, Serialize)] struct Server { name: String, url: String, signup_url: String, - user_count: u32, + user_count: Option, want_users: bool, admin_email: String, description: String, - users: Vec, + users: Option>, } #[derive(Debug, Deserialize, Serialize)] @@ -28,4 +32,10 @@ fn main() { println!(); println!("Path: {}", OUT_PATH); println!(); + + let conf = fs::read_to_string(CONF_PATH).expect("Could not read config file"); + let conf_yaml: Server = + serde_yaml::from_str(&conf).expect("Could not parse config data as YAML"); + + println!("{:#?}", conf_yaml); } -- cgit 1.4.1-2-gfad0