about summary refs log tree commit diff stats
path: root/src/main.rs
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-09-07 14:38:49 -0400
committerBen Morrison <ben@gbmor.dev>2019-09-07 14:38:49 -0400
commit194881ebf325f269891eb05c41c4bcf0baf3fed3 (patch)
tree34decf70c673b2b5a07fae85e26a6315e168eded /src/main.rs
parente79e6132b9e2a3dbb587021f781976110195a47f (diff)
downloadinstistats-194881ebf325f269891eb05c41c4bcf0baf3fed3.tar.gz
config file done
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 12 insertions, 2 deletions
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<u32>,
     want_users: bool,
     admin_email: String,
     description: String,
-    users: Vec<User>,
+    users: Option<Vec<User>>,
 }
 
 #[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);
 }
e>7
8
9
10
11
12
13
14