1#![forbid(unsafe_code)]
2#![forbid(clippy::all)]
3
4use std::env;
5use std::error::Error;
6use std::fs;
7
8pub mod compiler;
9pub mod generator;
10
11pub const DEFAULT_SCHEMA: &str = "public";
12pub const NAME: &str = env!("CARGO_PKG_NAME");
13pub const VERSION: &str = env!("CARGO_PKG_VERSION");
14
15pub fn compile(config: compiler::config::Config) -> Result<(), Box<dyn Error>> {
16 if let Some(err_msg) = config.validate() {
17 return Err(err_msg.into());
18 }
19
20 let sem_ast = dbml_rs::parse_file(&config.in_path)?;
21
22 let result = compiler::compile(sem_ast, &config)?;
23
24 fs::write(config.out_path, result.as_bytes())?;
25
26 Ok(())
27}