1pub mod audit;
24pub mod code_graph;
25pub mod executor;
26pub mod pipeline;
27pub mod typescript;
28
29pub use audit::{AuditOutput, AuditStep, AuditTrail, AuditTrailBuilder};
31pub use code_graph::{
32 CodeEnum, CodeField, CodeGraphBuilder, CodeImpl, CodeImport, CodeItem, CodeMethod, CodeModule,
33 CodeParam, CodeStruct, CodeTrait, CodeVariant,
34};
35pub use executor::{SyncExecutor, SyncResult, SyncedFileInfo, ValidationCheck};
36pub use pipeline::{
37 ExecutedRule, GeneratedFile, GenerationPipeline, PipelineState, RuleType, ValidationResult,
38 ValidationSeverity,
39};
40pub use typescript::TypeScriptGenerator;
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
48pub enum OutputFormat {
49 #[default]
51 Text,
52 Json,
54}
55
56impl std::str::FromStr for OutputFormat {
57 type Err = String;
58
59 fn from_str(s: &str) -> Result<Self, Self::Err> {
60 match s.to_lowercase().as_str() {
61 "text" => Ok(OutputFormat::Text),
62 "json" => Ok(OutputFormat::Json),
63 _ => Err(format!(
64 "Invalid output format: '{}'. Expected 'text' or 'json'",
65 s
66 )),
67 }
68 }
69}
70
71impl std::fmt::Display for OutputFormat {
72 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
73 match self {
74 OutputFormat::Text => write!(f, "text"),
75 OutputFormat::Json => write!(f, "json"),
76 }
77 }
78}
79
80#[derive(Debug, Clone)]
85pub struct SyncOptions {
86 pub manifest_path: std::path::PathBuf,
88
89 pub output_dir: Option<std::path::PathBuf>,
91
92 pub dry_run: bool,
94
95 pub force: bool,
97
98 pub audit: bool,
100
101 pub selected_rules: Option<Vec<String>>,
103
104 pub verbose: bool,
106
107 pub watch: bool,
109
110 pub validate_only: bool,
112
113 pub output_format: OutputFormat,
115
116 pub timeout_ms: u64,
118}
119
120impl Default for SyncOptions {
121 fn default() -> Self {
122 Self {
123 manifest_path: std::path::PathBuf::from("ggen.toml"),
124 output_dir: None,
125 dry_run: false,
126 force: false,
127 audit: false,
128 selected_rules: None,
129 verbose: false,
130 watch: false,
131 validate_only: false,
132 output_format: OutputFormat::default(),
133 timeout_ms: 30000, }
135 }
136}
137
138impl SyncOptions {
139 pub fn new() -> Self {
141 Self::default()
142 }
143
144 pub fn from_manifest<P: AsRef<std::path::Path>>(path: P) -> Self {
146 Self {
147 manifest_path: path.as_ref().to_path_buf(),
148 ..Self::default()
149 }
150 }
151
152 pub fn with_dry_run(mut self, dry_run: bool) -> Self {
154 self.dry_run = dry_run;
155 self
156 }
157
158 pub fn with_verbose(mut self, verbose: bool) -> Self {
160 self.verbose = verbose;
161 self
162 }
163
164 pub fn with_audit(mut self, audit: bool) -> Self {
166 self.audit = audit;
167 self
168 }
169
170 pub fn with_validate_only(mut self, validate_only: bool) -> Self {
172 self.validate_only = validate_only;
173 self
174 }
175
176 pub fn with_output_format(mut self, format: OutputFormat) -> Self {
178 self.output_format = format;
179 self
180 }
181
182 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
184 self.timeout_ms = timeout_ms;
185 self
186 }
187
188 pub fn with_rules(mut self, rules: Vec<String>) -> Self {
190 self.selected_rules = Some(rules);
191 self
192 }
193
194 pub fn with_force(mut self, force: bool) -> Self {
196 self.force = force;
197 self
198 }
199
200 pub fn with_output_dir<P: AsRef<std::path::Path>>(mut self, dir: P) -> Self {
202 self.output_dir = Some(dir.as_ref().to_path_buf());
203 self
204 }
205}