diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-03 21:27:52 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-03 21:27:52 +0200 |
commit | 3d107ea4710f3dec0eedd91ed5bc1e52d8f15912 (patch) | |
tree | 614a2110d1813c1f0df4170ac9932574c4e22c80 /src/config.rs | |
download | gpn-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.rs | 20 |
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"))?, + )?)?) + } +} |