1
0
Fork 0
codesnap.nvim/generator/src/path.rs

11 lines
282 B
Rust
Raw Normal View History

2024-03-16 15:10:35 +00:00
use regex::Regex;
use std::env::{var, VarError};
pub fn parse_save_path(path: String) -> Result<String, VarError> {
let home_path = var("HOME")?;
let regex = Regex::new(r"(~|$HOME)").unwrap();
let path = regex.replace_all(&path, home_path);
Ok(path.to_string())
}