summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs22
1 files changed, 20 insertions, 2 deletions
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;
2 2
3#[derive(Deserialize)] 3#[derive(Deserialize)]
4pub struct Config { 4pub struct Config {
5 pub apikey: String,
6 pub server: String, 5 pub server: String,
6 pub auth: Auth,
7}
8
9#[derive(Deserialize)]
10pub struct Auth {
11 pub method: Method,
12 pub secret: String,
13}
14
15#[derive(PartialEq, Eq, Deserialize)]
16pub enum Method {
17 None,
18 Key,
7} 19}
8 20
9impl Config { 21impl Config {
@@ -12,9 +24,15 @@ impl Config {
12 24
13 let builder = config::Config::builder(); 25 let builder = config::Config::builder();
14 26
27 let builder = builder
28 .set_default("auth.method", "none")?
29 .set_default("auth.secret", "")?;
30
15 let builder = if let Some(conf) = config_dir { 31 let builder = if let Some(conf) = config_dir {
16 let dir = conf.to_string_lossy(); 32 let dir = conf.to_string_lossy();
17 builder.add_source(config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false)) 33 builder.add_source(
34 config::File::with_name(format!("{dir}/webol-cli").as_str()).required(false),
35 )
18 } else { 36 } else {
19 println!("!No config dir found"); 37 println!("!No config dir found");
20 builder 38 builder