2023-05-19 00:03:14 +02:00
|
|
|
use structopt::StructOpt;
|
|
|
|
|
|
2023-06-18 13:53:45 +02:00
|
|
|
use crate::{
|
|
|
|
|
formats::data_format::DataFormat, formats::speed_unit::SpeedUnit, formats::temp_unit::TempUnit,
|
|
|
|
|
};
|
2023-06-08 23:10:21 +02:00
|
|
|
|
2023-05-19 00:03:14 +02:00
|
|
|
#[derive(Debug, StructOpt)]
|
2023-05-20 00:05:05 +02:00
|
|
|
#[structopt(
|
2023-05-20 00:35:47 +02:00
|
|
|
name = "open-meteo-cli",
|
2023-05-20 00:05:05 +02:00
|
|
|
about = "CLI to extract meteorology data from Open Meteo"
|
|
|
|
|
)]
|
|
|
|
|
pub enum Arguments {
|
2023-05-23 01:17:03 +02:00
|
|
|
#[structopt(
|
|
|
|
|
about = "Displays the current weather for your IP address automatically or for specific coordinates"
|
|
|
|
|
)]
|
2023-05-19 00:03:14 +02:00
|
|
|
CurrentWeather {
|
2023-05-23 01:17:03 +02:00
|
|
|
#[structopt(
|
|
|
|
|
short = "l",
|
|
|
|
|
long,
|
|
|
|
|
requires("longitude"),
|
|
|
|
|
help = "Latitude as a decimal number"
|
|
|
|
|
)]
|
|
|
|
|
latitude: Option<f64>,
|
|
|
|
|
#[structopt(
|
|
|
|
|
short = "L",
|
|
|
|
|
long,
|
|
|
|
|
requires("latitude"),
|
|
|
|
|
help = "Longitude as a decimal number"
|
|
|
|
|
)]
|
|
|
|
|
longitude: Option<f64>,
|
2023-05-19 00:03:14 +02:00
|
|
|
|
2023-05-21 02:27:37 +02:00
|
|
|
// Flags
|
2023-05-23 01:17:03 +02:00
|
|
|
#[structopt(short = "a", long, help = "Displays all the information")]
|
2023-05-20 00:05:05 +02:00
|
|
|
all: bool,
|
2023-06-13 18:38:32 +02:00
|
|
|
#[structopt(short = "d", long, help = "Displays if it is day or night")]
|
2023-05-19 00:03:14 +02:00
|
|
|
is_day: bool,
|
2023-06-08 23:10:21 +02:00
|
|
|
#[structopt(short = "t", long, help = "Displays the decimal temperature")]
|
2023-05-19 00:03:14 +02:00
|
|
|
temperature: bool,
|
2023-06-13 18:41:14 +02:00
|
|
|
#[structopt(long, possible_values = &TempUnit::variants(), default_value = "Celsius" , case_insensitive = true,
|
2023-06-08 23:10:21 +02:00
|
|
|
help = "Switches between Celsius or Fahrenheit")]
|
|
|
|
|
temperature_unit: TempUnit,
|
|
|
|
|
#[structopt(short = "w", long, help = "Displays the decimal wind speed")]
|
2023-05-19 00:03:14 +02:00
|
|
|
windspeed: bool,
|
2023-06-13 18:41:14 +02:00
|
|
|
#[structopt(long, possible_values = &SpeedUnit::variants(), default_value = "Kmh" , case_insensitive = true,
|
2023-06-08 23:10:21 +02:00
|
|
|
help = "Switches between km/h, m/s, mp/h or knots")]
|
|
|
|
|
speed_unit: SpeedUnit,
|
2023-05-23 01:17:03 +02:00
|
|
|
#[structopt(short = "W", long, help = "Displays the wind direction, in degrees")]
|
2023-05-19 00:03:14 +02:00
|
|
|
winddirection: bool,
|
2023-05-23 01:17:03 +02:00
|
|
|
#[structopt(long = "coords", help = "Displays the latitude and the longitude")]
|
|
|
|
|
include_coords: bool,
|
|
|
|
|
#[structopt(long = "city", help = "Displays the city")]
|
|
|
|
|
include_city: bool,
|
2023-06-13 18:41:14 +02:00
|
|
|
|
|
|
|
|
#[structopt(long, possible_values = &DataFormat::variants(), default_value = "Normal" , case_insensitive = true,
|
2023-06-13 18:38:32 +02:00
|
|
|
help = "Switches data format between Normal, Clean or JSON")]
|
|
|
|
|
format: DataFormat,
|
2023-06-13 18:41:14 +02:00
|
|
|
|
2023-05-19 00:03:14 +02:00
|
|
|
#[structopt(
|
|
|
|
|
short = "c",
|
|
|
|
|
long,
|
2023-06-13 18:38:32 +02:00
|
|
|
help = "Displays the output separated by commas. Same as '--format clean'
|
2023-05-23 01:17:03 +02:00
|
|
|
- ORDER: latitude, longitude, city, is_day, temperature, windspeed, winddirection"
|
2023-05-19 00:03:14 +02:00
|
|
|
)]
|
|
|
|
|
clean: bool,
|
2023-06-13 18:38:32 +02:00
|
|
|
#[structopt(
|
|
|
|
|
short = "j",
|
|
|
|
|
long,
|
|
|
|
|
help = "Displays the output as JSON. Same as '--format json'"
|
|
|
|
|
)]
|
|
|
|
|
json: bool,
|
2023-05-19 00:03:14 +02:00
|
|
|
},
|
|
|
|
|
}
|