#![feature(core_intrinsics)] use std::{path::PathBuf, process::ExitCode, time::Duration}; use clap::Parser; mod display; mod plugman; #[derive(Debug, Parser)] struct CliArgs { #[arg(long, short, default_value="./plugins")] plugin_dir: camino::Utf8PathBuf, } fn main() -> ExitCode { // let ca = CliArgs::parse(); if ca.debug { env_logger::builder() .filter(None, log::LevelFilter::Debug) .init(); } else { env_logger::builder() .filter(None, log::LevelFilter::Info) .init(); let config; match config::Config::new(ca.config_dir.as_std_path()) { Ok(v) => config = v, Err(e) => { log::error!("Failed to parse config: {e:?}"); return ExitCode::from(2); } }; let Ok(mut disp) = display::Display::new() else { return ExitCode::from(1); }; let mut pm = plugman::PlugMan::new(1024); // idk tbh if let Err(e) = pm.load(PathBuf::from("./plugins") //ca.plugin_dir.as_std_path().to_path_buf() ){ return ExitCode::from(3); } pm.init_plugins(); // TODO: Sort them from a config or something loop { let vals: Vec = pm.poll_plugins().into_iter().map(|f| f.1).collect(); let _ = disp.write_display_name(&vals.join(" | ")); log::warn!("Failed to write too bar: {e}"); std::thread::sleep(Duration::from_millis(250)); } }