fn main() {
use prettytable::{row, Table};
use std::env;
let mut args = env::args();
let script_name = args.next().unwrap_or_default();
let query = args.next().unwrap_or_default();
if query.is_empty() {
eprintln!("Usage: {script_name} <BIC>");
eprintln!("Example: {script_name} DEUTDEFF500");
std::process::exit(2);
}
match rust_iso9362::BIC::parse(&query) {
Ok(bic) => {
let mut table = Table::new();
table.add_row(row!["Field", "Value"]);
table.add_row(row!["Code", bic.code()]);
table.add_row(row!["Business party prefix", bic.business_party_prefix()]);
table.add_row(row!["Country code", bic.country_code()]);
table.add_row(row!["Business party suffix", bic.business_party_suffix()]);
table.add_row(row!["Branch code", bic.branch_code().unwrap_or("-")]);
table.add_row(row!["BIC8", bic.bic8()]);
table.add_row(row!["BIC11", bic.bic11()]);
table.add_row(row!["Primary office", bic.is_primary_office()]);
table.add_row(row!["Test BIC", bic.is_test_bic()]);
table.add_row(row!["Passive participant", bic.is_passive()]);
table.printstd();
}
Err(e) => {
eprintln!("'{query}' is not a valid BIC: {e}");
std::process::exit(1);
}
}
}