feat: implement path normalization across commands

This commit is contained in:
Bohdan Triapitsyn
2025-12-25 01:25:52 +02:00
parent 359cfd45b1
commit b806b01c29
9 changed files with 205 additions and 64 deletions
@@ -0,0 +1,21 @@
use std::path::PathBuf;
pub fn expand_tilde_path(value: &str) -> PathBuf {
let trimmed = value.trim();
if trimmed.is_empty() {
return PathBuf::from(trimmed);
}
let home = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/"));
if trimmed == "~" {
return home;
}
if trimmed.starts_with("~/") || trimmed.starts_with("~\\") {
return home.join(&trimmed[2..]);
}
PathBuf::from(trimmed)
}