From: Geoffrey Allott Date: Sat, 6 Mar 2021 22:56:53 +0000 (+0000) Subject: change directory to config dir X-Git-Url: https://git.pointlesshacks.com/?a=commitdiff_plain;h=89fe9793cfbc8026bb8d4b045b369bf9ee5d0b65;p=pokerwave.git change directory to config dir --- diff --git a/pokerwave.toml b/pokerwave.toml index c6e98ba..718a42d 100644 --- a/pokerwave.toml +++ b/pokerwave.toml @@ -1,12 +1,12 @@ [log] -filter = "info" -style = "auto" +#filter = "info" +#style = "auto" [redis] -#addr = "redis://pokerwave:59f278cd2a96756d67884976f54c1e490d00cb4f7ff62c24a380680e5f5098a3@localhost/0" +#addr = "redis://localhost" [server] -bind = ["localhost:4343"] -site = "site" -cert = "cert/cert.pem" -key = "cert/key.pem" +#bind = ["localhost:8080"] +#site = "site" +#cert = "cert/cert.pem" +#key = "cert/key.pem" diff --git a/src/main.rs b/src/main.rs index 57b62ae..c4f4e96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,8 +3,10 @@ extern crate log; #[macro_use] extern crate serde_derive; +use std::env::set_current_dir; use std::fs::read_to_string; use std::future::Future; +use std::path::Path; use std::pin::Pin; use clap::{app_from_crate, crate_authors, crate_description, crate_name, crate_version, AppSettings, Arg, SubCommand}; @@ -79,7 +81,15 @@ async fn main() -> Result<(), tide::Error> { .get_matches(); let config = match matches.value_of_os("config") { - Some(path) => toml::from_str(&read_to_string(path)?)?, + Some(path) => { + let config = toml::from_str(&read_to_string(path)?)?; + if let Some(dir) = Path::parent(path.as_ref()) { + if !dir.as_os_str().is_empty() { + set_current_dir(dir)?; + } + } + config + } None => Config::default(), };