Skip to content

Commit

Permalink
add helper
Browse files Browse the repository at this point in the history
  • Loading branch information
the-shank committed Mar 29, 2024
1 parent 619bab9 commit 5983ab5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/common/parsers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ pub fn parse_dir(s: &str) -> Result<PathBuf> {
if path.is_dir() {
Ok(path)
} else {
Err(eyre!(format!("{} is not a directory", s)))
Err(eyre!("{} is not a directory", s))
}
}

#[allow(dead_code)]
pub fn parse_existing_file(path: &str) -> Result<PathBuf> {
let path = PathBuf::from(path);
if path.try_exists()? && path.is_file() {
Ok(path)
} else {
Err(eyre!("{} exists but is not a file", path.to_string_lossy()))
}
}

Expand Down

0 comments on commit 5983ab5

Please sign in to comment.