From 0425d45d32da5f102b37a3ec19f11334b96bcc95 Mon Sep 17 00:00:00 2001 From: michaelBelsanti Date: Sun, 9 Feb 2025 12:39:28 -0500 Subject: [PATCH] feat(cli): default to XDG_CONFIG_HOME if set --- src/input.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/input.rs b/src/input.rs index 2536e8b36..9f9fa277f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -320,10 +320,13 @@ impl Config { /// Constructs default path to config toml pub fn default_config_path() -> PathBuf { - let Some(mut config_path) = dirs::home_dir() else { - panic!("Could not infer config file path."); + let config_path = match std::env::var("XDG_CONFIG_HOME") { + Ok(path) => PathBuf::from(path).join("rustscan.toml"), + Err(_) => dirs::home_dir() + .unwrap_or_else(|| panic!("Could not infer config file path.")) + .join(".rustscan.toml"), }; - config_path.push(".rustscan.toml"); + config_path }