Better print values and updating README

This commit is contained in:
2023-05-21 02:25:27 +02:00
parent 807e8071da
commit 87cd8701e7
3 changed files with 101 additions and 12 deletions
+23 -5
View File
@@ -26,7 +26,7 @@ fn main() {
}
let result = extract_weather(latitude, longitude);
let mut weather = result.unwrap_or_else(|_| {
let mut weather = result.unwrap_or_else(|_| {
eprintln!("[ERROR] Requesting current_weather for Latitude: {latitude}, Longitude: {longitude}");
exit(1);
});
@@ -43,25 +43,43 @@ fn main() {
let current_weather = CurrentWeather::new(current_weather_data, clean);
if is_day || all {
string_vec.push(current_weather.extract_data("is_day", "Is day"));
let is_day = current_weather.extract_raw("is_day");
if is_day == "1" {
string_vec.push(current_weather.parse_custom_data(is_day, "Day"));
} else {
string_vec.push(current_weather.parse_custom_data(is_day, "Night"));
}
}
if temperature || all {
string_vec.push(current_weather.extract_data("temperature", "Temperature"));
string_vec.push(current_weather.extract_simple_data(
"temperature",
"Temperature",
Some("°C"),
));
}
if windspeed || all {
string_vec.push(current_weather.extract_data("windspeed", "Wind speed"));
string_vec.push(current_weather.extract_simple_data(
"windspeed",
"Wind speed",
Some(" km/h"),
));
}
if winddirection || all {
string_vec.push(current_weather.extract_data("winddirection", "Wind direction"));
string_vec.push(current_weather.extract_simple_data(
"winddirection",
"Wind direction",
Some("°"),
));
}
if clean {
let final_string = string_vec.join(",");
println!("{final_string}");
} else {
string_vec.push(String::from("=== Weather data by Open-Meteo.com ==="));
let final_string = string_vec.join("\n");
println!("{final_string}");
}