diff options
author | FxQnLr <[email protected]> | 2024-04-10 12:06:45 +0200 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-04-10 12:06:45 +0200 |
commit | 352dd535e0386d899e816ac5f597e583d1ade768 (patch) | |
tree | 064522c02fb30b3804ee399fd2e77a3e10c3f289 /src/config.rs | |
parent | 23aa75439c3ee60e22ce183853516ca3cdd13ff4 (diff) | |
download | webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.tar webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.tar.gz webol-cli-352dd535e0386d899e816ac5f597e583d1ade768.zip |
Closes #8. 0.4.0 seems to work
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 |