use clap::{Arg, Command};
use thin_fetch::Repo;
fn main() {
let args = Command::new("get_head")
.arg(Arg::new("url").required(true).help("Repository URL"))
.get_matches_from(std::env::args());
let url = args.get_one::<String>("url").unwrap();
let repo = Repo::new_discover(url).unwrap();
match repo.get_ref("HEAD") {
Ok(Some(head)) => println!("{}", head.target()),
Ok(None) => eprintln!("head not found"),
Err(err) => eprintln!("error: {err}"),
}
}