From e926ea77d891c809be1e601c3fbf069617e42d6b Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Sat, 15 Nov 2025 15:19:36 +0300 Subject: Migtated to free open-meteo API --- src/main.rs | 75 ++++++++++++++++++------------------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index ffa33d3..7e150dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,68 +32,37 @@ SOFTWARE. extern crate image; -use clap::{Arg, Command}; +use std::os::linux::process; + +use clap::{Cli, Command, Subcommand}; use termimage::{Options}; mod parser; use parser::{get_config, Config}; // use crate::configmanager::{Config, handle_config}; - +#[derive(Subcommand)] +enum Commands { + Config, + Fetch, + Clean, + Help, + Today, + Tomorrow, + RebuildCache +} fn process_config() -> Result> { - get_config(); + let cfg: Config = get_config(); - Ok(Config::load()?) + Ok(cfg); } fn main() -> Result<(), Box> { - let config = Config::load()?; - let matches = Command::new("WeatherFetch") - .version("0.1") - .author("Borisov Alexey ") - .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::("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(()) -} + let config = process_config()?; + + + + } + + -- cgit v1.2.3