diff --git a/src/opt.rs b/src/opt.rs index 94eb6e005..0f90d47d1 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -251,7 +251,7 @@ pub struct BuildOpts { pub recipe: Vec, /// The directory that contains recipes. - #[arg(long)] + #[arg(long, value_parser = is_dir)] pub recipe_dir: Option, /// Build recipes up to the specified package. @@ -332,6 +332,17 @@ pub struct BuildOpts { pub skip_existing: SkipExisting, } +fn is_dir(dir: &str) -> Result { + let path = PathBuf::from(dir); + if path.is_dir() { + Ok(path) + } else { + Err(format!( + "Path '{dir}' needs to exist on disk and be a directory.", + )) + } +} + /// Test options. #[derive(Parser)] pub struct TestOpts {