aboutsummaryrefslogtreecommitdiffstats
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
parente79e6132b9e2a3dbb587021f781976110195a47f (diff)
downloadinstistats-194881ebf325f269891eb05c41c4bcf0baf3fed3.tar.gz
config file done
-rw-r--r--instistats.yml7
-rw-r--r--src/main.rs14
2 files changed, 19 insertions, 2 deletions
diff --git a/instistats.yml b/instistats.yml
new file mode 100644
index 0000000..3c2ad02
--- /dev/null
+++ b/instistats.yml
@@ -0,0 +1,7 @@
+# Config file for instistats
+name: "tilde.institute"
+url: "https://tilde.institute"
+signup_url: "https://tilde.institute/signup"
+want_users: true
+admin_email: "admins@tilde.institute"
+description: "A place in the tildeverse for people to explore and develop software for the OpenBSD operating system." \ No newline at end of file
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);
}