From 3d107ea4710f3dec0eedd91ed5bc1e52d8f15912 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 3 Jun 2024 21:27:52 +0200 Subject: code --- src/config.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/config.rs (limited to 'src/config.rs') 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 { + Ok(toml::from_str(&read_to_string( + std::env::args() + .nth(1) + .ok_or(anyhow!("first arg is the config"))?, + )?)?) + } +} -- cgit v1.2.3-70-g09d2