aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-03 21:27:52 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-03 21:27:52 +0200
commit3d107ea4710f3dec0eedd91ed5bc1e52d8f15912 (patch)
tree614a2110d1813c1f0df4170ac9932574c4e22c80 /src/config.rs
downloadgpn-tron-rust-3d107ea4710f3dec0eedd91ed5bc1e52d8f15912.tar
gpn-tron-rust-3d107ea4710f3dec0eedd91ed5bc1e52d8f15912.tar.bz2
gpn-tron-rust-3d107ea4710f3dec0eedd91ed5bc1e52d8f15912.tar.zst
code
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"))?,
+ )?)?)
+ }
+}