use clap::{Parser, Subcommand};
use colored::*;
use std::process;
mod commands;
mod docker;
mod config;
mod error;
mod utils;
pub mod assets;
#[derive(Parser)]
#[command(name = "zeckit")]
#[command(about = "ZecKit - Developer toolkit for Zcash on Zebra", long_about = None)]
#[command(version)]
struct Cli {
#[arg(long, global = true)]
project_dir: Option<String>,
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Up {
#[arg(short, long, default_value = "lwd")]
backend: String,
#[arg(short, long)]
fresh: bool,
#[arg(long, default_value = "10")]
timeout: u64,
#[arg(long)]
action_mode: bool,
#[arg(long)]
miner_address: Option<String>,
#[arg(long)]
fund_address: Option<String>,
#[arg(long, default_value = "10.0")]
fund_amount: f64,
#[arg(long, default_value = "ghcr.io/intellidean/zeckit")]
image_prefix: Option<String>,
},
Down {
#[arg(short, long)]
purge: bool,
},
Status,
Test {
#[arg(long, default_value = "0.05")]
amount: f64,
#[arg(long, default_value = "ZecKit E2E Transaction")]
memo: String,
#[arg(long)]
action_mode: bool,
},
#[command(long_about = "Generates a standardized GitHub Actions workflow (.github/workflows/zeckit-e2e.yml) that automatically spins up a 2-node Zebra cluster, configured with your choice of privacy backend and an embedded shielded faucet.")]
Init {
#[arg(short, long, default_value = "lwd", value_parser = ["zaino", "lwd"])]
backend: String,
#[arg(short, long)]
force: bool,
#[arg(short, long)]
output: Option<String>,
},
}
#[tokio::main]
async fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Up { backend, fresh, timeout, action_mode, miner_address, fund_address, fund_amount, image_prefix } => {
commands::up::execute(backend, fresh, timeout, action_mode, miner_address, fund_address, fund_amount, cli.project_dir, image_prefix).await
}
Commands::Down { purge } => {
commands::down::execute(purge, cli.project_dir).await
}
Commands::Status => {
commands::status::execute(cli.project_dir).await
}
Commands::Test { amount, memo, action_mode } => {
commands::test::execute(amount, memo, action_mode, cli.project_dir).await
}
Commands::Init { backend, force, output } => {
commands::init::execute(backend, force, output, cli.project_dir).await
}
};
if let Err(e) = result {
eprintln!("{} {}", "Error:".red().bold(), e);
process::exit(1);
}
}