From c214e1c59e54b895e32c332afc6bb8e897b01d0e Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Wed, 26 Mar 2025 14:49:15 +0300 Subject: Fixing errs --- src/configmanager.rs | 15 ++++++++------- src/main.rs | 34 +++++++++++++++++++++++++--------- src/parser.rs | 8 ++++---- 3 files changed, 37 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/configmanager.rs b/src/configmanager.rs index 0bbbb73..c0047a5 100644 --- a/src/configmanager.rs +++ b/src/configmanager.rs @@ -17,6 +17,14 @@ pub struct Config { pub snowy: String, } +pub fn handle_config(_config: &Config) -> Result<(), Box> { + Ok(()) +} + +pub fn gen_standard_conf() { + // TODO: Implement +} + impl Config { pub fn load() -> Result> { let mut path = home_dir().ok_or("Home directory not found")?; @@ -28,10 +36,3 @@ impl Config { } } -pub fn handle_config(_config: &Config) -> Result<(), Box> { - Ok(()) -} - -pub fn gen_standard_conf() { - // TODO: Implement -} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 4f15b56..9f64ca4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,14 @@ -use clap::{Arg, Command}; -use termimage; +extern crate image; + + +use clap::{Arg, Command}; +use termimage::{Options}; + mod configmanager; mod parser; -use configmanager::{Config, handle_config}; +use crate::configmanager::{Config, handle_config}; fn main() -> Result<(), Box> { let matches = Command::new("WeatherFetch") @@ -19,11 +23,11 @@ fn main() -> Result<(), Box> { .arg(Arg::new("lon").short('n').long("lon").value_name("LONGITUDE")) .get_matches(); - if matches.contains_id("help") { - println!("Usage: ..."); - return Ok(()); - } - + if matches.contains_id("help") { + println!("Usage: ..."); + return Ok(()); + } + if let Some(img_path) = matches.get_one::("image") { let _img = Image::from_path(img_path)?; } @@ -31,5 +35,17 @@ fn main() -> Result<(), Box> { let config = Config::load()?; handle_config(&config)?; + + let opts = Options::parse(); + /* + if !opts { + opts = configmanager::Config::load(); + } + + let format = ops::guess_format(&opts.image)?; + let img = ops::load_image(&opts.image, format)?; + + */ + Ok(()) -} \ No newline at end of file +} diff --git a/src/parser.rs b/src/parser.rs index e8eff39..5a670b1 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2,7 +2,7 @@ use reqwest::{Error, Client, get}; use chrono::{DateTime, Utc, prelude::*}; use serde::{Serialize, Deserialize}; -use crate::configmanager::{Config}; +use crate::configmanager; //API answer struct`s #[derive(Debug, Serialize, Deserialize)] @@ -125,10 +125,10 @@ pub struct Alert { -pub fn get_location(let coords_args: bool, config: &Config) -> Result<(), String>{ +pub fn get_location(coords_args: bool) -> Result<(), String>{ //Get the lat and lon for API call - configmanager::handle_config(); - if Config.lat.is_empty() || Config.lon.is_empty() && !coords_args{ + let conf: Option; + if conf.lat.is_empty() || conf.lon.is_empty() && !coords_args{ println!("No coordinates in configuration file or conf not founded."); println!("HINT: Try create ~/.config/WeatherFetch/Config.toml"); println!("HINT: And add `lat()`, `lon()`."); -- cgit v1.2.3