Skip to content

Commit

Permalink
feat: error when recipe-dir is not a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian committed Jul 11, 2024
1 parent 184f8de commit 3f16475
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub struct BuildOpts {
pub recipe: Vec<PathBuf>,

/// The directory that contains recipes.
#[arg(long)]
#[arg(long, value_parser = is_dir)]
pub recipe_dir: Option<PathBuf>,

/// Build recipes up to the specified package.
Expand Down Expand Up @@ -332,6 +332,17 @@ pub struct BuildOpts {
pub skip_existing: SkipExisting,
}

fn is_dir(dir: &str) -> Result<PathBuf, String> {
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 {
Expand Down

0 comments on commit 3f16475

Please sign in to comment.