Add config iniitialization (I can totally spell)
This commit is contained in:
parent
6033a63446
commit
d86a5a7147
3 changed files with 26 additions and 5 deletions
7
packages/backend/Cargo.lock
generated
7
packages/backend/Cargo.lock
generated
|
@ -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"
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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<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
|
||||
|
||||
// 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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue