Something went wrong. Try again.
My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990//! Filaments//! My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
use std::{process, sync::Arc};
use crate::{cli::Cli, config::Config, deimos::Deimos, tui::TuiApp, viz::FilViz};
use clap::Parser;use fil_core::{Kasten, KastenHandle};use tokio::sync::{RwLock, mpsc};use tracing::debug;
mod cli;mod config;mod deimos;mod errors;mod filaments;mod logging;mod lsp;mod tui;mod viz;
fn main() -> color_eyre::Result<()> { errors::init()?; logging::init()?;
let args = Cli::parse();
let rt = Arc::new(tokio::runtime::Runtime::new()?);
// Handle commands if let Some(command) = args.command { return rt.block_on(async { command.process().await }); }
// Kasten let kh: KastenHandle = rt.block_on(async { let cfg = Config::parse()?;
debug!("Config: {cfg:#?}");
Ok::<KastenHandle, color_eyre::Report>(Arc::new(RwLock::new( Kasten::instansiate(cfg.fil_dir).await?, ))) })?;
debug!("Kasten Handle: {kh:#?}");
let (signal_tx, signal_rx) = mpsc::unbounded_channel();
// Spawn TUI in its own thread let tui_handle = std::thread::spawn({ let tui_rt = rt.clone(); let kh = kh.clone(); let signal_tx = signal_tx.clone();
move || -> color_eyre::Result<()> { tui_rt.block_on(async { let mut tui = TuiApp::new(args.tick_rate, args.frame_rate, kh, signal_tx)?; tui.run().await?; // Force close everything once TUI is done. process::exit(0); }) } });
if args.visualizer { // Enter the guard so `egui_async` works properly let _rt_guard = rt.enter();
// spawn Deimos: file watcher { let kh = kh.clone(); rt.spawn(async { let deimos = Deimos::new(kh, signal_tx); deimos.watch().await }); }
// Create an Index of the current contents let index = rt.block_on(async { kh.read().await.index.clone() });
// run the visualizer FilViz::run(kh, signal_rx, &index)?; }
tui_handle.join().unwrap()?; Ok(())}