// Common utilities shared across modules
/// Expand a leading "~/" to the user's home directory. If expansion fails, returns the input.
pub fn expand_tilde(path: &str) -> String {
if let Some(rest) = path.strip_prefix("~/") {
if let Some(home) = dirs::home_dir() {
return home.join(rest).to_string_lossy().into_owned();
}
}
path.to_string()
}