This commit is contained in:
2026-02-07 20:36:00 +08:00
commit f46084d3fe
16 changed files with 1432 additions and 0 deletions

17
src/helpers/mod.rs Normal file
View File

@@ -0,0 +1,17 @@
use std::path::PathBuf;
pub const FILE_EXTENSION: &str = "mg";
pub(crate) fn expand_tilde(path: PathBuf) -> color_eyre::Result<PathBuf> {
if path.starts_with("~") {
let Some(home) = dirs::home_dir() else {
return Err(color_eyre::eyre::eyre!("No home directory found"));
};
if path == PathBuf::from("~") {
return Ok(home);
}
let relative = path.strip_prefix("~")?;
return Ok(home.join(relative));
}
Ok(path)
}