Add cli validator: is_existing_path()

This commit is contained in:
Matthias Beyer 2016-09-30 10:47:11 +02:00
parent 3d06933860
commit f8ed44c1e7
1 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,10 @@
use std::path::PathBuf;
use boolinator::Boolinator;
pub fn is_existing_path(s: String) -> Result<(), String> {
PathBuf::from(s.clone()).exists().as_result((), format!("Not a File or Directory: {}", s))
}
pub fn is_file(s: String) -> Result<(), String> {
PathBuf::from(s.clone()).is_file().as_result((), format!("Not a File: {}", s))
}