main.rs 46 lignes · 1107 octets
//! Interactive CLI wizard for scaffolding Rustwarden projects.

mod start_project;
mod templates;
mod update_project;
mod version;

use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "rustwarden-cli",
    version,
    about = "CLI wizard for scaffolding Rustwarden applications"
)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    /// Create a new Rustwarden application project
    StartProject,
    /// Update the framework crates in an existing project
    UpdateProject,
}

fn main() {
    let cli = Cli::parse();

    match cli.command {
        Commands::StartProject => {
            if let Err(e) = start_project::run() {
                eprintln!("{}", console::style(format!("Erreur: {e}")).red().bold());
                std::process::exit(1);
            }
        }
        Commands::UpdateProject => {
            if let Err(e) = update_project::run() {
                eprintln!("{}", console::style(format!("Erreur: {e}")).red().bold());
                std::process::exit(1);
            }
        }
    }
}