pub trait LanguageCodegen {
// Required methods
fn language(&self) -> &'static str;
fn file_extension(&self) -> &'static str;
fn preview(&self) -> Vec<PreviewFile>;
fn generate(&self, output_dir: &Path) -> Result<GenerateResult, Report>;
// Provided methods
fn clean(&self, _output_dir: &Path) -> Result<CleanResult, Report> { ... }
fn preview_clean(&self, _output_dir: &Path) -> Result<CleanResult, Report> { ... }
}Expand description
Trait for language-specific code generators.
Implement this trait to add support for generating CLI code in a new language.
Required Methods§
Sourcefn file_extension(&self) -> &'static str
fn file_extension(&self) -> &'static str
File extension for generated source files (e.g., “rs”, “ts”, “go”)
Sourcefn preview(&self) -> Vec<PreviewFile>
fn preview(&self) -> Vec<PreviewFile>
Preview generated files without writing to disk
Provided Methods§
Sourcefn clean(&self, _output_dir: &Path) -> Result<CleanResult, Report>
fn clean(&self, _output_dir: &Path) -> Result<CleanResult, Report>
Clean orphaned generated files.
Removes:
- Generated command files that are no longer in the manifest
- Unmodified handler stubs that are no longer in the manifest
Handler files that have been modified by the user are not deleted.
Default implementation returns an empty result (no cleaning).
Sourcefn preview_clean(&self, _output_dir: &Path) -> Result<CleanResult, Report>
fn preview_clean(&self, _output_dir: &Path) -> Result<CleanResult, Report>
Preview what would be cleaned without actually deleting files.
Default implementation returns an empty result.