Added config file
Some checks failed
Continuous integration / Check (push) Failing after 1m45s
Continuous integration / Test Suite (push) Failing after 2m15s
Continuous integration / Rustfmt (push) Failing after 34s
Continuous integration / Clippy (push) Failing after 1m50s
Continuous integration / build (push) Failing after 2m13s

This commit is contained in:
Luke Else 2025-02-22 16:03:35 +00:00
parent 253b7ce9a9
commit c58405c5cb
7 changed files with 38 additions and 7 deletions

View File

@ -6,12 +6,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
egui = "0.28.1"
eframe = "0.28.1"
tracing-subscriber = "0.3.16"
strum = { version = "0.26.3", features = ["derive"] }
tokio = { version = "1.39.2", features = ["full"] }
tokio-macros = { version = "2.4.0" }
egui = "0.31.0"
eframe = "0.31.0"
tracing-subscriber = "0.3.19"
strum = { version = "0.27.1", features = ["derive"] }
tokio = { version = "1.43.0", features = ["full"] }
tokio-macros = { version = "2.5.0" }
async-trait = "0.1.86"
futures = "0.3.31"
reqwest = "0.12.12"
serde_yaml = "0.9.34"
serde = {version = "1.0.218", features = ["derive"]}

1
config.yml Normal file
View File

@ -0,0 +1 @@
metar_url: "https://tgftp.nws.noaa.gov/data/observations/metar/stations/"

View File

@ -2,9 +2,12 @@ mod metar;
mod req;
mod ui;
use crate::utils::config;
/// Stuct to store the state of the running application
pub struct App<'a> {
pub name: &'a str,
pub config: config::Config,
tab_state: ui::tabs::TabState,
}
@ -13,6 +16,7 @@ impl<'a> Default for App<'a> {
fn default() -> Self {
Self {
name: "AvBag - Welcome",
config: config::Config::new(),
tab_state: ui::tabs::TabState::default(),
}
}

View File

@ -53,7 +53,7 @@ impl Tab for MetarTab {
let metar_clone = Arc::clone(&self.metar);
task::spawn(async move {
let metar = metar_clone.lock().await;
match metar.api.make_request(String::from("https://google.co.uk")).await {
match metar.api.make_request(String::from("")).await {
Ok(response) => println!("{:?}", response),
Err(e) => eprintln!("Request failed: {:?}", e),
}

View File

@ -2,6 +2,7 @@
mod app;
mod error;
mod theme;
mod utils;
use app::App;
use egui::ViewportBuilder;
@ -18,6 +19,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a box to the app and then pass into app creator
let app = Box::new(App::default());
println!("App: {:?}", app.config);
//Start rendering and run the application
Ok(eframe::run_native(app.name, options, Box::new(|_cc| Ok(app)))?)

20
src/utils/config.rs Normal file
View File

@ -0,0 +1,20 @@
use serde::Deserialize;
const DEFAULT_CONFIG: &str = "./config.yml";
#[derive(Debug, Default, Deserialize)]
pub struct Config {
pub metar_url: String,
}
impl Config {
pub fn new() -> Self {
Config::from_file().unwrap()
}
pub fn from_file() -> Result<Self, Box<dyn std::error::Error>> {
let config_content = std::fs::read_to_string(DEFAULT_CONFIG)?;
let config: Config = serde_yaml::from_str(&config_content)?;
Ok(config)
}
}

1
src/utils/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod config;