From b8eafd5fa25186d430aee0fa3378dbc5a2c9ce2e Mon Sep 17 00:00:00 2001 From: Joshua Lane Date: Sun, 12 Jan 2025 12:26:45 -0800 Subject: [PATCH] fix: error when default config file already exists --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index fc5f8cb..5f5b0ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -144,6 +144,10 @@ impl Args { let config_path = shellexpand::tilde(&self.config_file).into_owned(); let path = PathBuf::from(config_path); + if path.exists() { + return Err(anyhow!("Config file `{}` already exists", path.display())); + } + if let Some(parent) = path.parent() { std::fs::create_dir_all(parent)?; }