morph-cli 0.1.0

AST-based codebase migration and codemod tool for JavaScript and TypeScript projects.
Documentation
use crate::core::plugins::{PluginManifest, PluginRegistry};
use anyhow::Result;

pub fn execute(name: &str) -> Result<()> {
    let mut registry = PluginRegistry::new();
    let reports = registry.discover(std::path::Path::new("."));

    for report in &reports {
        if report.name == name {
            if let Ok(manifest) = PluginManifest::from_path(&report.path) {
                print_plugin_info(&manifest);
                return Ok(());
            } else if let Some(err) = &report.error {
                anyhow::bail!("Invalid plugin: {}", err);
            }
        }
    }

    anyhow::bail!("Plugin not found: {}", name)
}

fn print_plugin_info(manifest: &crate::core::plugins::PluginManifest) {
    println!("Plugin: {}", manifest.name);
    println!("Version: {}", manifest.version);

    if let Some(desc) = &manifest.description {
        println!("Description: {}", desc);
    }

    if let Some(author) = &manifest.author {
        println!("Author: {}", author.name);
        if let Some(email) = &author.email {
            println!("  Email: {}", email);
        }
        if let Some(url) = &author.url {
            println!("  URL: {}", url);
        }
    }

    println!("\nRecipes ({}):", manifest.recipes.len());
    for recipe in &manifest.recipes {
        println!("  - {}", recipe.name);
        if let Some(desc) = &recipe.description {
            println!("      {}", desc);
        }
    }

    println!("\nCompatibility:");
    println!("  morph-cli: {}", manifest.compatibility.morph_cli_version);

    if let Some(langs) = &manifest.compatibility.language {
        println!("  Languages: {:?}", langs);
    }
}