From 486e6431b1b4f29d58a196a328f2018639455d1e Mon Sep 17 00:00:00 2001 From: Philipp Reiter Date: Sat, 23 Nov 2024 17:27:46 +0100 Subject: [PATCH] Make wireman work with a default install path --- wireman-config/src/setup.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wireman-config/src/setup.rs b/wireman-config/src/setup.rs index e1285e6..5194aa4 100644 --- a/wireman-config/src/setup.rs +++ b/wireman-config/src/setup.rs @@ -7,7 +7,8 @@ use std::path::Path; use logger::Logger; use crate::config::{HistoryConfig, LoggingConfig}; -use crate::{Config, CONFIG_FNAME, ENV_CONFIG_DIR}; +use crate::install::expand_path; +use crate::{Config, CONFIG_FNAME, DEFAULT_CONFIG_DIR, ENV_CONFIG_DIR}; use theme::Theme; use crate::error::{Error, Result}; @@ -130,14 +131,15 @@ pub fn setup(dry_run: bool) -> Result { } fn config_dir_checked() -> StdResult { - let config_dir = var(ENV_CONFIG_DIR).map_err(|_| SetupError::ConfigDirEnvNotFound)?; + let config_dir = var(ENV_CONFIG_DIR).unwrap_or(DEFAULT_CONFIG_DIR.to_string()); + let config_dir_expanded = expand_path(&config_dir); - let config_path = Path::new(&config_dir); + let config_path = Path::new(&config_dir_expanded); if config_dir.is_empty() || !config_path.exists() { return Err(SetupError::ConfigDirInvalid); } - Ok(config_dir) + Ok(config_dir_expanded) } fn config_file_checked(config_path: &Path) -> StdResult {