1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
use std::process; use crate::{api::fetch_address, Ui}; pub fn run(code: &str) { let postal_code = code.replace("-", ""); if postal_code.len() != 7 { eprintln!("Please enter the postcode with 7digit like following: `kenall-rs 1000000` or `kenall-rs 100-0000`"); process::exit(1); } let result = fetch_address(&postal_code).unwrap(); if result.data.is_empty() { eprintln!("Sorry, there was no address associated with the post code"); process::exit(1); } Ui::display_address(&result); }