aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: eea7991b3012607d24b47c43b9ef41cd621a2b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::{bot, 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,
    pub bot: bot::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"))?,
        )?)?)
    }
}