summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-06-17 11:19:13 +0200
committerGitHub <[email protected]>2024-06-17 11:19:13 +0200
commitb375657e660b199127a76683980a5d210a572ab7 (patch)
treefbed775283917537c1d2d11bdbf38a0fa7c05a02 /src/config.rs
parent31a57425a76cae121c5d8ef5b0f2442ca6a9ee61 (diff)
parent0877850a63791772dd19a0af9a0c7c87940aead2 (diff)
downloadwebol-cli-769df24cfefc3cc41fe308e1bfa6ee04d5ea65aa.tar
webol-cli-769df24cfefc3cc41fe308e1bfa6ee04d5ea65aa.tar.gz
webol-cli-769df24cfefc3cc41fe308e1bfa6ee04d5ea65aa.zip
Merge pull request #9 from FxQnLr/0.3.0HEAD0.3.0main
0.3.0
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