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