diff options
author | FxQnLr <[email protected]> | 2024-06-17 11:19:13 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-06-17 11:19:13 +0200 |
commit | b375657e660b199127a76683980a5d210a572ab7 (patch) | |
tree | fbed775283917537c1d2d11bdbf38a0fa7c05a02 /src/config.rs | |
parent | 31a57425a76cae121c5d8ef5b0f2442ca6a9ee61 (diff) | |
parent | 0877850a63791772dd19a0af9a0c7c87940aead2 (diff) | |
download | webol-cli-b375657e660b199127a76683980a5d210a572ab7.tar webol-cli-b375657e660b199127a76683980a5d210a572ab7.tar.gz webol-cli-b375657e660b199127a76683980a5d210a572ab7.zip |
0.3.0
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 22 |
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)] |
4 | pub struct Config { | 4 | pub struct Config { |
5 | pub apikey: String, | ||
6 | pub server: String, | 5 | pub server: String, |
6 | pub auth: Auth, | ||
7 | } | ||
8 | |||
9 | #[derive(Deserialize)] | ||
10 | pub struct Auth { | ||
11 | pub method: Method, | ||
12 | pub secret: String, | ||
13 | } | ||
14 | |||
15 | #[derive(PartialEq, Eq, Deserialize)] | ||
16 | pub enum Method { | ||
17 | None, | ||
18 | Key, | ||
7 | } | 19 | } |
8 | 20 | ||
9 | impl Config { | 21 | impl 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 |