use crate::errors::TbError;
use std::path::PathBuf;
#[derive(Debug, Clone, Default)]
pub struct CodegenOptions {
pub(crate) spec: Option<PathBuf>,
pub(crate) output: Option<PathBuf>,
pub(crate) test: Option<bool>,
pub(crate) update: Option<bool>,
pub(crate) separate_files: Option<bool>,
}
impl CodegenOptions {
pub fn new() -> Self {
Self::default()
}
pub fn spec(&mut self, spec: impl Into<PathBuf>) -> &mut Self {
self.spec = Some(spec.into());
self
}
pub fn spec_option(&mut self, spec: Option<PathBuf>) -> &mut Self {
self.spec = spec;
self
}
pub fn output(&mut self, output: impl Into<PathBuf>) -> &mut Self {
self.output = Some(output.into());
self
}
pub fn output_option(&mut self, output: Option<PathBuf>) -> &mut Self {
self.output = output;
self
}
pub fn test(&mut self, test: impl Into<Option<bool>>) -> &mut Self {
self.test = test.into();
self
}
pub fn update(&mut self, update: impl Into<Option<bool>>) -> &mut Self {
self.update = update.into();
self
}
pub fn separate_files(&mut self, separate_files: impl Into<Option<bool>>) -> &mut Self {
self.separate_files = separate_files.into();
self
}
pub fn codegen(&self) -> Result<(), TbError> {
super::codegen(self)
}
}