aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..678074e
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,20 @@
+use crate::{game, spectate};
+use anyhow::{anyhow, Result};
+use serde::Deserialize;
+use std::fs::read_to_string;
+
+#[derive(Deserialize)]
+pub struct Config {
+ pub game: game::Config,
+ pub spectate: spectate::Config,
+}
+
+impl Config {
+ pub fn load() -> Result<Self> {
+ Ok(toml::from_str(&read_to_string(
+ std::env::args()
+ .nth(1)
+ .ok_or(anyhow!("first arg is the config"))?,
+ )?)?)
+ }
+}