1use std::path::Path;
2
3pub mod checks;
4pub mod config;
5mod io;
6pub mod report;
7pub mod run;
8
9pub use checks as check;
10pub use run::{run, EntityOutcome, RunOutcome};
11
12pub type FloeResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
13
14#[derive(Debug)]
15pub(crate) struct ConfigError(pub(crate) String);
16
17impl std::fmt::Display for ConfigError {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 write!(f, "{}", self.0)
20 }
21}
22
23impl std::error::Error for ConfigError {}
24
25#[derive(Debug, Default)]
26pub struct ValidateOptions {
27 pub entities: Vec<String>,
28}
29
30#[derive(Debug, Default)]
31pub struct RunOptions {
32 pub run_id: Option<String>,
33 pub entities: Vec<String>,
34}
35
36pub fn validate(config_path: &Path, options: ValidateOptions) -> FloeResult<()> {
37 let config = config::parse_config(config_path)?;
38 config::validate_config(&config)?;
39
40 if !options.entities.is_empty() {
41 run::validate_entities(&config, &options.entities)?;
42 }
43
44 Ok(())
45}
46
47pub fn load_config(config_path: &Path) -> FloeResult<config::RootConfig> {
48 config::parse_config(config_path)
49}