From 352dd535e0386d899e816ac5f597e583d1ade768 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Wed, 10 Apr 2024 12:06:45 +0200 Subject: Closes #8. 0.4.0 seems to work --- src/config.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 769269c..01ab097 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,8 +2,20 @@ use serde::Deserialize; #[derive(Deserialize)] pub struct Config { - pub apikey: String, pub server: String, + pub auth: Auth, +} + +#[derive(Deserialize)] +pub struct Auth { + pub method: Method, + pub secret: String, +} + +#[derive(PartialEq, Eq, Deserialize)] +pub enum Method { + None, + Key, } impl Config { @@ -12,9 +24,15 @@ impl Config { let builder = config::Config::builder(); + let builder = builder + .set_default("auth.method", "none")? + .set_default("auth.secret", "")?; + let builder = if let Some(conf) = config_dir { let dir = conf.to_string_lossy(); - builder.add_source(config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false)) + builder.add_source( + config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false), + ) } else { println!("!No config dir found"); builder -- cgit v1.2.3