summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-03-24 21:42:48 +0300
committerNamilskyy <alive6863@gmail.com>2025-03-24 21:43:40 +0300
commit667a259c981df9f08c49d4fe83fc2f907be06784 (patch)
tree3453e544a913339107b8a6bcb9269e69ab5a57f8 /src
parent8ccbfad0cc8ecdcdccaa8766a7316b6a56d5e615 (diff)
Start dev
Diffstat (limited to 'src')
-rw-r--r--src/Config.toml0
-rw-r--r--src/configmanager.rs24
-rw-r--r--src/main.rs86
-rw-r--r--src/parser.rs141
4 files changed, 251 insertions, 0 deletions
diff --git a/src/Config.toml b/src/Config.toml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/Config.toml
diff --git a/src/configmanager.rs b/src/configmanager.rs
new file mode 100644
index 0000000..e046aa2
--- /dev/null
+++ b/src/configmanager.rs
@@ -0,0 +1,24 @@
+use std::fs;
+use serde::Deserialize;
+
+impl WeatherFetch{
+#[derive(Deserialize)]
+pub struct Config {
+ lat: String, //Latitude, decimal (-90; 90)
+ lon: String, //Longitude, decimal (-180; 180)
+ exclude: String, //By using this parameter you can exclude some parts of the weather
+ appid: String, //Your OpenWeatherMap API key
+ lang: String, //Output language
+ units: String, //Units of measurement
+ cache: bool //Cacheing next Weather to dont use internet in next call
+ rain: String, //Path to rain image (png/jpg) or ASCII art int .txt
+ sunny: String, //Path to sunny image (png/jpg) or ASCII art int .txt
+ snowy: String,
+ //More info: OpenWeatherMap.org/api/one-call3
+}
+
+pub fn handle_config() -> Result<(), Box<dyn std::error::Error>>{
+ let Config_str = fs::read_to_string("~/.config/WeatherFetch/Config.toml");
+ let Config_parse: Config = toml::from_str(&data)?.except();
+}
+}
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..5119def
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,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(())
+}
+
diff --git a/src/parser.rs b/src/parser.rs
new file mode 100644
index 0000000..37d0885
--- /dev/null
+++ b/src/parser.rs
@@ -0,0 +1,141 @@
+mod condfigmanager
+
+use reqwest::{Error, Client, get};
+use chrono::{DateTime, Utc, prelude::*};
+use serde::{Serialize, Deserealize};
+use std::net::{IpAddr, SocketAddr, UpdSocket};
+use tokio;
+
+static ErrBuff: String = reqwest::Error;
+
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct WeatherData {
+ pub lat: f64,
+ pub lon: f64,
+ pub timezone: String,
+ pub timezone_offset: i32,
+ pub current: Current,
+ pub minutely: Vec<Minutely>,
+ pub hourly: Vec<Hourly>,
+ pub daily: Vec<Daily>,
+ pub alerts: Vec<Alert>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Current {
+ pub dt: u64,
+ pub sunrise: u64,
+ pub sunset: u64,
+ pub temp: f32,
+ pub feels_like: f32,
+ pub pressure: u32,
+ pub humidity: u32,
+ pub dew_point: f32,
+ pub uvi: f32,
+ pub clouds: u32,
+ pub visibility: u32,
+ pub wind_speed: f32,
+ pub wind_deg: u32,
+ pub wind_gust: f32,
+ pub weather: Vec<Weather>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Weather {
+ pub id: u32,
+ pub main: String,
+ pub description: String,
+ pub icon: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Minutely {
+ pub dt: u64,
+ pub precipitation: f32,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Hourly {
+ pub dt: u64,
+ pub temp: f32,
+ pub feels_like: f32,
+ pub pressure: u32,
+ pub humidity: u32,
+ pub dew_point: f32,
+ pub uvi: f32,
+ pub clouds: u32,
+ pub visibility: u32,
+ pub wind_speed: f32,
+ pub wind_deg: u32,
+ pub wind_gust: f32,
+ pub weather: Vec<Weather>,
+ pub pop: f32,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Daily {
+ pub dt: u64,
+ pub sunrise: u64,
+ pub sunset: u64,
+ pub moonrise: u64,
+ pub moonset: u64,
+ pub moon_phase: f32,
+ pub summary: String,
+ pub temp: Temp,
+ pub feels_like: FeelsLike,
+ pub pressure: u32,
+ pub humidity: u32,
+ pub dew_point: f32,
+ pub wind_speed: f32,
+ pub wind_deg: u32,
+ pub wind_gust: f32,
+ pub weather: Vec<Weather>,
+ pub clouds: u32,
+ pub pop: f32,
+ pub rain: Option<f32>,
+ pub uvi: f32,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Temp {
+ pub day: f32,
+ pub min: f32,
+ pub max: f32,
+ pub night: f32,
+ pub eve: f32,
+ pub morn: f32,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct FeelsLike {
+ pub day: f32,
+ pub night: f32,
+ pub eve: f32,
+ pub morn: f32,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Alert {
+ pub sender_name: String,
+ pub event: String,
+ pub start: u64,
+ pub end: u64,
+ pub description: String,
+ pub tags: Vec<String>,
+}
+:qa
+
+
+:q
+
+async fn get_location(let ip: String) -> Reslut<(), >{
+ let ip: String = reqwest::get("https://api.ipify.org").await?.text.await?;
+}
+
+
+#[tokio::main]
+async pub fn parse_wheather() -> Result<(), Error>{
+
+}