diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-11-17 22:17:55 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-11-18 22:03:57 +0300 |
| commit | 9b772a55055d863982cbcc3ba7900c26f156c23d (patch) | |
| tree | 13bf3ad95d3f233ad26b0ef356b5ab7777b82d0b | |
| parent | 3218f90ea64a7e85a186225db4763703f53cc773 (diff) | |
Some fixes and first building release
| -rw-r--r-- | src/main.rs | 39 |
1 files changed, 37 insertions, 2 deletions
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<dyn std::error::Error>> { 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) => { |
