change directory to config dir
authorGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 22:56:53 +0000 (22:56 +0000)
committerGeoffrey Allott <geoffrey@allott.email>
Sat, 6 Mar 2021 22:56:53 +0000 (22:56 +0000)
pokerwave.toml
src/main.rs

index c6e98ba03f8891db5582f59380b89c1dcfc2c3a3..718a42d3034d59d6ce636eb1c63cf04fff46ce13 100644 (file)
@@ -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"
index 57b62ae53493032a920f0dbf112ac9ceee215567..c4f4e963c3d4bab0765a719a430a2f030234e738 100644 (file)
@@ -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(),
     };