Add config iniitialization (I can totally spell)

This commit is contained in:
s1idewhist1e 2023-05-09 00:13:21 -07:00
parent 6033a63446
commit d86a5a7147
No known key found for this signature in database
GPG key ID: 9CC756BB9B325062
3 changed files with 26 additions and 5 deletions

View file

@ -13,6 +13,7 @@ name = "backend"
version = "0.0.0" version = "0.0.0"
dependencies = [ dependencies = [
"config", "config",
"lazy_static",
"logging", "logging",
"queue", "queue",
"server", "server",
@ -49,6 +50,12 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "logging" name = "logging"
version = "0.1.0" version = "0.1.0"

View file

@ -21,5 +21,6 @@ server = { path = "crates/server" }
logging = { path = "crates/logging" } logging = { path = "crates/logging" }
queue = { path = "crates/queue" } queue = { path = "crates/queue" }
config = { path = "crates/config" } config = { path = "crates/config" }
lazy_static = "1.4.0"
[dev-dependencies] [dev-dependencies]

View file

@ -1,17 +1,30 @@
use std::{
env, error, fmt,
path::{Path, PathBuf},
};
use std::{path::Path, error::Error};
#[cfg(debug_assertions)]
extern crate config; extern crate config;
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn error::Error>> {
env::set_var(
"CK_REPO_DIR",
PathBuf::from(env!("PWD"))
.parent()
.and_then(|p| p.parent())
.ok_or(fmt::Error)?,
);
// bootstrap // bootstrap
// ENV // ENV
// get config // 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(()) Ok(())
} }