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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
//In developing 🏗️
use serde::{Serialize, Deserialize};
use std::{env, path::Path};
use clap::{Arg, Command};
use termimage::{Image};
mod parser;
mod configmanagerж
use parser::{parse_weather, Weather};
use configmanager::{Config, handle_config};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let matches = Command::new("WeatherFetch")
.version("0.1")
.author("Borisov Alexey <arcanetmodl@gmail.com>")
.about("Weather fetch like fastfetch with image and ASCII art support. Just useless pet project.")
.arg(
Arg::new("image")
.short("i")
.long("image")
.value_name("PATH")
.help("Path to image file")
.takes_value(true),
)
.arg(
Arg::new("exclude")
.short("e")
.long("exclude")
.value_name("TYPE")
.possible_values(["current", "minutely", "hourly", "daily", "alerts"])
.help("Exclude specific weather data type")
.takes_value(true),
)
.arg(
Arg::new("help")
.short("h")
.long("help")
.help("Print help information")
.takes_value(false),
)
.arg(
Arg::new(lat)
.short("lt")
.long("lat")
.value_name("TWO DIGITS")
.help("Coordinates for weather API call. Latitude.")
.takes_value(true)
)
.arg(
Arg::new("lon")
.short("ln")
.long("lon")
.value_name("TWO DIGITS")
.help("Coordinates for weather API call. Latitude.")
.takes_value(true)
)
.get_matches();
if matches.is_present("help") {
return Ok(());
}
if let Some(img_path) = matches.value_of("image") {
let img = Image::from_path(img_path)?;
}
if let Some(exclude_type) = matches.value_of("exclude") {
}
let config = Config::load()?;
handle_config(&config)?;
Ok(())
}
|