Files
boco/src/main.rs
T
marvin 37f537184c
CI / build (pull_request) Successful in 10s
CI / build (push) Successful in 11s
refactor: split main.rs into registry, build, and qemu modules
main.rs keeps only the CLI definition and command dispatch:
- registry.rs: image-name validation + XDG registry path handling (tests)
- build.rs: podman mount/unmount, vmlinuz extraction, cpio/gzip initrd
- qemu.rs: direct-kernel-boot VM launch

No behavior change; cargo fmt/clippy/test pass, build/run paths
verified against the mock-vm image.
2026-08-26 20:15:16 +00:00

44 lines
987 B
Rust

mod build;
mod qemu;
mod registry;
use anyhow::Result;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(about = "Build bootable initrd VMs from container images")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
enum Commands {
/// Build initrd from an image (podman image must exist)
Build {
/// Image name (e.g. alpine:3.15 or slim:tag)
image: String,
/// Size hint (unused in v1 initrd)
#[arg(short = 's', long, default_value = "512")]
_size: String,
},
/// Launch the VM via QEMU using registry artifacts
Run {
/// Image tag / registry subdir name
name: String,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Build { image, _size: _ } => {
build::build(&image)?;
}
Commands::Run { name } => {
qemu::run(&name)?;
}
}
Ok(())
}