use anyhow::{Context as _, Result}; use std::str::FromStr as _; #[tokio::main] async fn main() -> Result<()> { let mut args = std::env::args(); args.next().context("Expected app name as arg0")?; let lat = args.next().context("Usage: weather_dot_gov $LAT $LON")?; let lon = args.next().context("Usage: weather_dot_gov $LAT $LON")?; let client = reqwest::Client::new(); let req = client .get("https://forecast.weather.gov/MapClick.php") .query(&[ ("lat", lat.as_str()), ("lon", lon.as_str()), ("unit", "0"), ("lg", "english"), ("FcstType", "dwml"), ]) .header("user-agent", "weather_dot_gov_rs") .build()?; let res = client.execute(req).await?; let body = res.text().await?; let dwml = weather_dot_gov_rs::Dwml::from_str(&body)?; println!("{dwml:#?}"); Ok(()) }