Adding format to select between normal, clean and JSON. This needs some refactor

This commit is contained in:
2023-06-13 18:38:32 +02:00
parent 9978e1553b
commit 8a3e5783c2
10 changed files with 507 additions and 306 deletions
+15 -4
View File
@@ -1,6 +1,6 @@
use structopt::StructOpt;
use crate::{temp_unit::TempUnit, speed_unit::SpeedUnit};
use crate::{temp_unit::TempUnit, speed_unit::SpeedUnit, data_format::DataFormat};
#[derive(Debug, StructOpt)]
#[structopt(
@@ -30,7 +30,7 @@ pub enum Arguments {
// Flags
#[structopt(short = "a", long, help = "Displays all the information")]
all: bool,
#[structopt(short = "d", long, help = "Displays if it's day or night")]
#[structopt(short = "d", long, help = "Displays if it is day or night")]
is_day: bool,
#[structopt(short = "t", long, help = "Displays the decimal temperature")]
temperature: bool,
@@ -50,13 +50,24 @@ pub enum Arguments {
include_coords: bool,
#[structopt(long = "city", help = "Displays the city")]
include_city: bool,
#[structopt(long,
possible_values = &DataFormat::variants(), default_value = "Normal" , case_insensitive = true,
help = "Switches data format between Normal, Clean or JSON")]
format: DataFormat,
#[structopt(
short = "c",
long,
help = "Cleans the output and only displays the values separated by commas.
help = "Displays the output separated by commas. Same as '--format clean'
- ORDER: latitude, longitude, city, is_day, temperature, windspeed, winddirection"
)]
clean: bool,
#[structopt(
short = "j",
long,
help = "Displays the output as JSON. Same as '--format json'"
)]
json: bool,
},
}