30 lines
678 B
Rust
30 lines
678 B
Rust
use config::Config;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::path::PathBuf;
|
|
use structopt::StructOpt;
|
|
|
|
#[derive(StructOpt)]
|
|
pub struct Args {
|
|
pub config_path: PathBuf,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DaemonConfig {
|
|
pub discord_api_token: String,
|
|
pub db_path: PathBuf,
|
|
}
|
|
|
|
impl DaemonConfig {
|
|
pub fn new(config: PathBuf) -> DaemonConfig {
|
|
let daemon_config = Config::builder()
|
|
.add_source(config::File::new(
|
|
config.to_str().unwrap(),
|
|
config::FileFormat::Toml,
|
|
))
|
|
.build()
|
|
.unwrap();
|
|
|
|
daemon_config.try_deserialize().unwrap()
|
|
}
|
|
}
|