From 9b772a55055d863982cbcc3ba7900c26f156c23d Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Mon, 17 Nov 2025 22:17:55 +0300 Subject: Some fixes and first building release --- src/main.rs | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 057588b..d232ef0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ mod parser; mod shared; use parser::{get_config, parse_weather, generate_config, Config}; -use shared::WeatherData; +use shared::{WeatherData, Current, Hourly}; #[derive(Parser)] #[command(name = "wfetch")] @@ -152,7 +152,42 @@ fn main() -> Result<(), Box> { Ok(()) }, Some(Commands::Today) => { - println!("Today weather command"); + let data: WeatherData = parse_cached()?; + + println!("╔═══════════════════════════════════════╗"); + println!("║ Today`s weather ║"); + println!("╠═══════════════════════════════════════╣"); + println!("║ Time: {} {}", format!("{:>28}", data.current.time), "║"); + println!("║ Temp: {}°C {}" , format!("{:>22}", data.current.temperature_2m), "║"); + println!("║ Wind speed: {} m/s {}", format!("{:>19}", data.current.wind_speed_10m), "║"); + if let Some(elevation) = data.elevation { + println!("║ Height: {} m {}", format!("{:>26}", elevation), "║"); + } + if let Some(timezone) = &data.timezone { + println!("║ Time: {} {}", format!("{:>22}", timezone), "║"); + } + println!("║ Coords: {:.2}, {:.2}, {}", data.latitude, data.longitude, "║"); + println!("╚═══════════════════════════════════════╝"); + + + if !data.hourly.time.is_empty() { + println!("┌──────────────┬──────────────┬──────────────┬──────────────┐"); + println!("│ Time │ Temp │ Humidity │ Wind │"); + println!("├──────────────┼──────────────┼──────────────┼──────────────┤"); + + let hours_to_show = data.hourly.time.len().min(24); + for i in 0..hours_to_show { + let time = &data.hourly.time[i]; + let temp = data.hourly.temperature_2m[i]; + let humidity = data.hourly.relative_humidity_2m[i]; + let wind = data.hourly.wind_speed_10m[i]; + + println!("│ {:12} │ {:>10}°C │ {:>10}% │ {:>10} m/s │", + time, temp, humidity, wind); + } + println!("└──────────────┴──────────────┴──────────────┴──────────────┘"); + } + Ok(()) }, Some(Commands::Tomorrow) => { -- cgit v1.2.3