diff --git a/Cargo.lock b/Cargo.lock index 5e4f6a1..6a58f57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1880,6 +1880,7 @@ dependencies = [ "config", "crypto-hash", "ctrlc", + "dirs", "dotenvy", "ed25519", "ed25519-dalek", @@ -1974,6 +1975,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "display-error-chain" version = "0.2.0" @@ -4134,6 +4156,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -4593,6 +4625,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "ordered-multimap" version = "0.6.0" @@ -5374,6 +5412,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror", +] + [[package]] name = "regex" version = "1.10.5" diff --git a/Cargo.toml b/Cargo.toml index 30a811b..777e440 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,4 +51,5 @@ mockall = "0.12.1" keystore = { git = "https://github.com/deltadevsde/keystore", rev = "40f21a41afd0654091bb0881665288034ab8533f" } pyroscope = "0.5.7" pyroscope_pprofrs = "0.2.7" -toml = "0.8.14" \ No newline at end of file +toml = "0.8.14" +dirs = "5.0.1" \ No newline at end of file diff --git a/src/cfg.rs b/src/cfg.rs index 5860705..73f8154 100644 --- a/src/cfg.rs +++ b/src/cfg.rs @@ -1,5 +1,6 @@ use clap::{Parser, Subcommand}; use config::{builder::DefaultState, ConfigBuilder, File}; +use dirs::home_dir; use serde::{Deserialize, Serialize}; use std::{fs, path::Path, sync::Arc}; @@ -134,9 +135,10 @@ impl Default for Config { } pub fn load_config(args: CommandLineArgs) -> Result { - let config_path = args - .config_path - .unwrap_or_else(|| ".deimos/config.toml".to_string()); + let config_path = args.config_path.unwrap_or_else(|| { + let home_dir = home_dir().expect("Failed to get home directory"); + format!("{}/.deimos/config.toml", home_dir.to_string_lossy()) + }); // if the config file doesn't exist, create it with the default values if !Path::new(&config_path).exists() { @@ -155,7 +157,7 @@ pub fn load_config(args: CommandLineArgs) -> Result let default_config = Config::default(); let file_config: Config = settings.try_deserialize().unwrap_or_else(|e| { - debug!("Failed to deserialize config file: {}", e); + error!("deserializing config file: {}", e); Config::default() });