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
|
/*
_______ ________ __________
___ |__________________ _______________ __ \_______ __ ___ ___ \
__ /| |_ ___/ ___/ __ `/_ __ \ _ \_ / / / _ \_ | / / __ / _ \ |
_ ___ | / / /__ / /_/ /_ / / / __/ /_/ // __/_ |/ / _ / , _/ /
/_/ |_/_/ \___/ \__,_/ /_/ /_/\___//_____/ \___/_____/ |_/_/|_|_/
*/
extern crate image;
use clap::{Arg, Command};
use termimage::{Options};
mod configmanager;
mod parser;
use crate::configmanager::{Config, handle_config};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::load()?;
let matches = Command::new("WeatherFetch")
.version("0.1")
.author("Borisov Alexey <arcanetmodl@gmail.com>")
.about("Weather fetch with image and ASCII art support")
.arg(Arg::new("image").short('i').long("image").value_name("PATH"))
.arg(Arg::new("exclude").short('e').long("exclude").value_name("TYPE")
.value_parser(["current", "minutely", "hourly", "daily", "alerts"]))
.arg(Arg::new("help").short('h').long("help"))
.arg(Arg::new("lat").short('t').long("lat").value_name("LATITUDE"))
.arg(Arg::new("lon").short('n').long("lon").value_name("LONGITUDE"))
.get_matches();
if matches.contains_id("help") {
println!("Usage:");
println!("VALUES");
println!("--img=, -i= image, takees a path to .jpg/.png");
println!("--lat=, -t=, coordinates: takes f64.");
println!("--lon=, -n=, coordinates: takes f64");
println!("--cfg=, -c=, takes a path to Config.toml");
println!("--exclude=, -e=, takes exlude type. See the API docs");
println!("FUNCTIONS");
println!("--gen-conf, -g, generating standart config");
println!("--alerts, -a, show alerts");
return Ok(());
}
if let Some(img_path) = matches.get_one::<String>("image") {
let _img = image::open(img_path)?;
}
handle_config(&config)?;
let _opts = Options::parse(); // Prefix with underscore if not used
/*
if !opts {
opts = configmanager::Config::load();
}
let format = ops::guess_format(&opts.image)?;
let img = ops::load_image(&opts.image, format)?;
*/
Ok(())
}
|