LanguageCodegen

Trait LanguageCodegen 

Source
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>;

    // Provided methods
    fn clean(&self, _output_dir: &Path) -> Result<CleanResult> { ... }
    fn preview_clean(&self, _output_dir: &Path) -> Result<CleanResult> { ... }
}
Expand description

Trait for language-specific code generators.

Implement this trait to add support for generating CLI code in a new language.

Required Methods§

Source

fn language(&self) -> &'static str

Language identifier (e.g., “rust”, “typescript”, “go”)

Source

fn file_extension(&self) -> &'static str

File extension for generated source files (e.g., “rs”, “ts”, “go”)

Source

fn preview(&self) -> Vec<PreviewFile>

Preview generated files without writing to disk

Source

fn generate(&self, output_dir: &Path) -> Result<GenerateResult>

Generate all files into the specified output directory

Provided Methods§

Source

fn clean(&self, _output_dir: &Path) -> Result<CleanResult>

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).

Source

fn preview_clean(&self, _output_dir: &Path) -> Result<CleanResult>

Preview what would be cleaned without actually deleting files.

Default implementation returns an empty result.

Implementors§