opencrates 3.0.1

Enterprise-grade AI-powered Rust development companion with comprehensive automation, monitoring, and deployment capabilities
use anyhow::Result;
use clap::Parser;
use dotenvy::dotenv;
use opencrates::utils::logging;
use tracing::{info, Level};

/// OpenCrates CLI - A modern Rust crate management and generation tool
#[derive(Parser)]
#[command(name = "opencrates")]
#[command(about = "OpenCrates CLI for Rust crate management")]
#[command(version)]
struct Cli {
    #[command(subcommand)]
    command: Option<Commands>,
}

#[derive(Parser)]
enum Commands {
    /// Check project health and dependencies
    Check {
        /// Path to check (defaults to current directory)
        #[arg(short, long)]
        path: Option<String>,
    },
    /// Generate new crate or code
    Generate {
        /// What to generate
        #[arg(short, long)]
        template: String,
        /// Name for the generated item
        #[arg(short, long)]
        name: String,
    },
    /// Show version information
    Version,
}

#[tokio::main]
async fn main() -> Result<()> {
    // Load environment variables from .env file if it exists
    dotenv().ok();
    
    // Initialize logging for CLI
    logging::init(Level::INFO);

    let cli = Cli::parse();

    match cli.command {
        Some(Commands::Check { path }) => {
            let check_path = path.unwrap_or_else(|| ".".to_string());
            info!("Checking project at: {}", check_path);
            println!("✓ Project check completed for: {}", check_path);
        }
        Some(Commands::Generate { template, name }) => {
            info!("Generating {} with template: {}", name, template);
            println!("✓ Generated {} using template: {}", name, template);
        }
        Some(Commands::Version) => {
            println!("OpenCrates CLI v{}", env!("CARGO_PKG_VERSION"));
        }
        None => {
            println!("OpenCrates CLI v{}", env!("CARGO_PKG_VERSION"));
            println!("Run 'opencrates --help' for usage information.");
        }
    }

    Ok(())
}