use std::{ sync::{Arc, Mutex}, thread, }; use geekbar_core::{prompt::work_params_handler, work::WorksExecutor}; fn main() -> anyhow::Result<()> { let works_executor = Arc::new(Mutex::new(WorksExecutor::default())); let receiver = works_executor.lock().unwrap().receiver().clone(); let executor = works_executor.clone(); let handle = thread::spawn(move || { while let Ok(work_params) = receiver.recv() { if let Some(work_params) = work_params { let work_params = work_params_handler(work_params).unwrap(); executor .lock() .unwrap() .send_params(work_params, None) .unwrap(); } else { std::process::exit(0); } } }); let args = std::env::args().collect::>(); let params = args.get(1); works_executor.lock().unwrap().execute_workflow_file( "examples/search/workflow.json", "search", params, )?; handle.join().unwrap(); Ok(()) }