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