wingmate-rs/src/init.rs

29 lines
717 B
Rust
Raw Normal View History

2023-11-22 12:45:00 +00:00
mod daemon;
mod config;
pub(crate) mod error;
2023-11-25 04:46:49 +00:00
use std::env;
2023-11-22 12:45:00 +00:00
use std::error as std_err;
pub async fn start() -> Result<(), Box<dyn std_err::Error>> {
2023-11-25 04:46:49 +00:00
let mut vec_search: Vec<String> = Vec::new();
match env::var("WINGMATE_CONFIG_PATH") {
Ok(paths) => {
for p in paths.split(':') {
vec_search.push(String::from(p));
}
},
Err(e) => {
if let env::VarError::NotUnicode(_) = e {
return Err(e.into());
} else {
vec_search.push(String::from("/etc/wingmate"));
}
}
}
let config = config::Config::find(vec_search)?;
dbg!(&config);
daemon::start(config).await
2023-11-22 12:45:00 +00:00
}