1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#[derive(PartialEq, Clone)]
pub struct Arguments {
// pub no_tui: bool,
// pub location: String,
pub help: bool,
pub summary: bool,
// pub forecast: i32,
}
pub fn parse() -> Arguments {
let mut it = std::env::args().skip(1); // skip program name
// let mut no_tui = false;
// let mut location = String::from("Stockholm");
let mut help = false;
let mut summary = false;
// let mut forecast = DEF_FORECAST;
while let Some(arg) = it.next() {
match arg.as_str() {
// "-l" => {
// location = it
// .next()
// .expect("No location was given after the \"-l\" flag.");
// }
"help" | "-h" | "h" => {
help = true;
}
"summary" | "-s" | "s" => {
summary = true;
}
// "-t" => {
// no_tui = true;
// }
// "-f" => {
// // use next if some and parse to i32, else default
// forecast = it
// .next()
// .as_deref()
// .unwrap_or(format!("{}", DEF_FORECAST).as_str())
// .parse::<i32>()
// .unwrap_or(DEF_FORECAST);
// }
_ => {}
}
}
// if forecast > MAX_FORECAST {
// forecast = MAX_FORECAST
// }
Arguments {
// no_tui,
// location,
help,
summary,
// forecast,
}
}