diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-09-30 10:47:11 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-09-30 10:47:11 +0200 |
commit | f8ed44c1e70fd6c2c1c8d6b021f4e43d7c99c17a (patch) | |
tree | 99eb1d88b27e44c5c55578d997c8decdb54d306a /libimagutil | |
parent | 3d06933860f9286ef6117f43e7fc8aca9615c843 (diff) |
Add cli validator: is_existing_path()
Diffstat (limited to 'libimagutil')
-rw-r--r-- | libimagutil/src/cli_validators.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libimagutil/src/cli_validators.rs b/libimagutil/src/cli_validators.rs index ed102ca5..068d5834 100644 --- a/libimagutil/src/cli_validators.rs +++ b/libimagutil/src/cli_validators.rs @@ -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)) } |