From d86a5a714774a15f3e561f39f934db6bc33cd026 Mon Sep 17 00:00:00 2001 From: s1idewhist1e Date: Tue, 9 May 2023 00:13:21 -0700 Subject: [PATCH] Add config iniitialization (I can totally spell) --- packages/backend/Cargo.lock | 7 +++++++ packages/backend/Cargo.toml | 1 + packages/backend/src/main.rs | 23 ++++++++++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/backend/Cargo.lock b/packages/backend/Cargo.lock index 75bbeb4637..821851f11e 100644 --- a/packages/backend/Cargo.lock +++ b/packages/backend/Cargo.lock @@ -13,6 +13,7 @@ name = "backend" version = "0.0.0" dependencies = [ "config", + "lazy_static", "logging", "queue", "server", @@ -49,6 +50,12 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "logging" version = "0.1.0" diff --git a/packages/backend/Cargo.toml b/packages/backend/Cargo.toml index cd2a0dc480..bca8257e36 100644 --- a/packages/backend/Cargo.toml +++ b/packages/backend/Cargo.toml @@ -21,5 +21,6 @@ server = { path = "crates/server" } logging = { path = "crates/logging" } queue = { path = "crates/queue" } config = { path = "crates/config" } +lazy_static = "1.4.0" [dev-dependencies] diff --git a/packages/backend/src/main.rs b/packages/backend/src/main.rs index 174211ee14..bc5198c3f7 100644 --- a/packages/backend/src/main.rs +++ b/packages/backend/src/main.rs @@ -1,17 +1,30 @@ +use std::{ + env, error, fmt, + path::{Path, PathBuf}, +}; -use std::{path::Path, error::Error}; - -#[cfg(debug_assertions)] extern crate config; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { + env::set_var( + "CK_REPO_DIR", + PathBuf::from(env!("PWD")) + .parent() + .and_then(|p| p.parent()) + .ok_or(fmt::Error)?, + ); // bootstrap // ENV // get config - config::init_config(Path::new(""))?; + config::init_config( + &Path::new(&env::var("CK_REPO_DIR")?) + .join(".config") + .join("default.yml"), + )?; + println!("{:?}", config::get_config()?); Ok(()) }