use chrono::Utc;
use std::env;
use std::fs;
pub fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 3 {
println!("Usage: `call <CLUBLOGXML> <CALLSIGN>`");
} else {
let file = &args[1];
let call = &args[2];
let raw = fs::read_to_string(file).unwrap();
let clublog = hamcall::clublog::ClubLog::parse(&raw).unwrap();
let clublogmap = hamcall::clublogmap::ClubLogMap::from(clublog);
let timestamp = Utc::now();
match hamcall::call::analyze_callsign(&clublogmap, call, ×tamp) {
Ok(c) => {
if hamcall::call::check_whitelist(&clublogmap, &c, ×tamp) {
println!("{} => {:?}", call, c)
} else {
println!(
"Callsign matches to entity {} but is not whitelisted",
c.dxcc.unwrap()
)
}
}
Err(e) => eprintln!("{} => {:?}", call, e),
}
}
}