use heroforge_core::sync::quic::QuicServer;
use heroforge_core::Repository;
use std::env;
use std::path::PathBuf;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 3 {
eprintln!("Usage: {} <repo.forge> <port>", args[0]);
std::process::exit(1);
}
let repo_path = PathBuf::from(&args[1]);
let port: u16 = args[2].parse().expect("Invalid port");
let addr = format!("127.0.0.1:{}", port);
let repo = Repository::open(&repo_path).expect("Failed to open repository");
let rt = tokio::runtime::Runtime::new().expect("Failed to create runtime");
rt.block_on(async {
let server = QuicServer::bind(&addr).expect("Failed to bind");
println!("READY on {}", addr);
match server.handle_sync(&repo, &repo_path).await {
Ok(stats) => {
println!("SUCCESS");
println!(
"Sent: {} artifacts, {} bytes",
stats.artifacts_sent, stats.bytes_sent
);
println!(
"Received: {} artifacts, {} bytes",
stats.artifacts_received, stats.bytes_received
);
if stats.skipped > 0 {
println!("Skipped: {} artifacts", stats.skipped);
}
}
Err(e) => {
eprintln!("FAILED: {}", e);
std::process::exit(1);
}
}
});
}