From f252c6a119a9fbc3038011a47e1f69c79f3a3741 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 5 May 2021 21:04:53 +0200 Subject: [PATCH] feat(path): include argument to force config and runtime directories --- espanso-path/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/espanso-path/src/lib.rs b/espanso-path/src/lib.rs index 0f9cc69..1b1e8e0 100644 --- a/espanso-path/src/lib.rs +++ b/espanso-path/src/lib.rs @@ -30,8 +30,10 @@ pub struct Paths { pub packages: PathBuf, } -pub fn resolve_paths() -> Paths { - let config_dir = if let Some(config_dir) = get_config_dir() { +pub fn resolve_paths(force_config_dir: Option<&Path>, force_runtime_dir: Option<&Path>) -> Paths { + let config_dir = if let Some(config_dir) = force_config_dir { + config_dir.to_path_buf() + } else if let Some(config_dir) = get_config_dir() { config_dir } else { // Create the config directory if not already present @@ -41,7 +43,9 @@ pub fn resolve_paths() -> Paths { config_dir }; - let runtime_dir = if let Some(runtime_dir) = get_runtime_dir() { + let runtime_dir = if let Some(runtime_dir) = force_runtime_dir { + runtime_dir.to_path_buf() + } else if let Some(runtime_dir) = get_runtime_dir() { runtime_dir } else { // Create the runtime directory if not already present