pub mod condition;
pub mod context;
pub mod dependency;
pub mod executor;
pub mod models;
pub mod parser;
pub mod reporter;
pub mod testing;
pub mod validator;
#[cfg(test)]
mod tests;
pub use context::ExecutionContext;
pub use executor::{CollectionExecutor, ExecutionOptions};
pub use models::{Collection, CollectionRequest};
pub use parser::parse_collection;
pub use reporter::{ConsoleReporter, Reporter};
pub use validator::validate_collection;
use anyhow::Result;
use std::path::{Path, PathBuf};
pub fn list_collections(collections_dir: &Path) -> Result<Vec<PathBuf>> {
let mut collections = Vec::new();
if !collections_dir.exists() {
return Ok(collections);
}
for entry in std::fs::read_dir(collections_dir)? {
let entry = entry?;
let path = entry.path();
if path.is_file() {
if let Some(ext) = path.extension() {
if ext == "yaml" || ext == "yml" {
collections.push(path);
}
}
}
}
collections.sort();
Ok(collections)
}
pub fn find_collection(collections_dir: &Path, name: &str) -> Result<PathBuf> {
for ext in &["yaml", "yml"] {
let path = collections_dir.join(format!("{}.{}", name, ext));
if path.exists() {
return Ok(path);
}
}
let path = collections_dir.join(name);
if path.exists() && path.is_file() {
return Ok(path);
}
anyhow::bail!("Collection '{}' not found in {:?}", name, collections_dir)
}