summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 4f15b56e9f18f1e08922497abc12900283dff8fd (plain)
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
use clap::{Arg, Command};
use termimage; 

mod configmanager;
mod parser;

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 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: ...");
        return Ok(());
    }

    if let Some(img_path) = matches.get_one::<String>("image") {
        let _img = Image::from_path(img_path)?;
    }

    let config = Config::load()?;
    handle_config(&config)?;

    Ok(())
}