use clap::{Parser, Subcommand};
mod commands;
mod render;
#[derive(Parser)]
#[command(name = "hd", about = "Hyperdocker — incremental container runtime")]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init,
Up,
Down,
Status,
Exec {
#[arg(trailing_var_arg = true)]
cmd: Vec<String>,
},
Ingest {
path: String,
},
Lock,
Dag {
#[command(subcommand)]
action: DagAction,
},
Cas {
#[command(subcommand)]
action: CasAction,
},
Demo {
path: Option<String>,
},
}
#[derive(Subcommand)]
enum DagAction {
Show,
}
#[derive(Subcommand)]
enum CasAction {
Stats,
Gc,
}
fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Init => commands::init::run(),
Commands::Up => commands::up::run(),
Commands::Down => commands::down::run(),
Commands::Status => commands::status::run(),
Commands::Exec { cmd } => commands::exec::run(&cmd),
Commands::Ingest { path } => commands::ingest::run(&path),
Commands::Lock => commands::lock::run(),
Commands::Dag { action } => match action {
DagAction::Show => commands::dag::run_show(),
},
Commands::Cas { action } => match action {
CasAction::Stats => commands::cas::run_stats(),
CasAction::Gc => commands::cas::run_gc(),
},
Commands::Demo { path } => commands::demo::run(path.as_deref()),
};
if let Err(e) = result {
eprintln!("error: {}", e);
std::process::exit(1);
}
}