diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..a0dfbbe --- /dev/null +++ b/src/config.rs | |||
@@ -0,0 +1,23 @@ | |||
1 | use config::{Config, File, FileFormat}; | ||
2 | use serde::Deserialize; | ||
3 | |||
4 | #[derive(Debug, Deserialize)] | ||
5 | pub struct Cfg { | ||
6 | pub apis: Apis, | ||
7 | } | ||
8 | |||
9 | #[derive(Debug, Deserialize)] | ||
10 | pub struct Apis { | ||
11 | pub modrinth: String, | ||
12 | } | ||
13 | |||
14 | impl Cfg { | ||
15 | pub fn init(path: &str) -> Self { | ||
16 | Config::builder() | ||
17 | .add_source(File::new(path, FileFormat::Ini)) | ||
18 | .build() | ||
19 | .unwrap() | ||
20 | .try_deserialize() | ||
21 | .unwrap() | ||
22 | } | ||
23 | } | ||