fixed dir flag not expanding

This commit is contained in:
Valerie Wolfe 2022-06-28 18:53:19 -04:00
parent 2449af240c
commit e9021abf60
3 changed files with 7 additions and 5 deletions

2
Cargo.lock generated
View file

@ -13,7 +13,7 @@ dependencies = [
[[package]]
name = "config"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"regex",
"toml",

View file

@ -1,6 +1,6 @@
[package]
name = "config"
version = "0.1.4"
version = "0.1.5"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -91,10 +91,12 @@ fn main() -> Result<(), Box<dyn Error>>{
if prop_path.is_none() {
error::no_property(entry, "path");
}
let i_file_path = prop_path.unwrap().as_str().unwrap();
let file_path = PathBuf::from(i_file_path);
let raw_path = prop_path.unwrap().as_str().unwrap();
let expanded = home_regex.replace(raw_path, &home_dir);
let file_path = PathBuf::from(expanded.to_string());
if file_path.is_dir() {
path = true;
println!("{}", expanded);
return Ok(());
} else {
let i_parent = file_path.parent().unwrap().to_str().unwrap();
let parent = home_regex.replace(i_parent, home_dir);