aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
blob: b489271873b136beafdbfe63c53af4195f655a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::{bot, database, game, spectate};
use anyhow::{anyhow, Result};
use serde::Deserialize;
use std::fs::read_to_string;

#[derive(Deserialize)]
pub struct Config {
    pub database: database::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"))?,
        )?)?)
    }
}