added auto update & changed config path

This commit is contained in:
Uber Veng
2026-05-21 22:59:02 +07:00
parent 1599cfcafa
commit f2349c9f15
7 changed files with 435 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ mod executor;
mod menu;
mod network;
mod ui;
mod updater;
use std::io;
use anyhow::Result;
@@ -30,6 +31,7 @@ async fn main() -> Result<()> {
let (event_tx, mut event_rx) = mpsc::unbounded_channel();
let mut app = app::App::new(config, event_tx.clone());
app.load_menu().await;
app.check_update();
let res = run_app(&mut terminal, &mut app, &mut event_rx).await;
@@ -71,6 +73,21 @@ async fn run_app(
break;
}
// Check for pending restart (after update applied) — before pending_exec.
if app.pending_restart {
disable_raw_mode()?;
execute!(
terminal.backend_mut(),
LeaveAlternateScreen,
DisableMouseCapture
)?;
terminal.show_cursor()?;
#[cfg(unix)]
updater::exec_updated();
// fallback for non-unix or if exec failed
break;
}
// After handling events, check if a script requested an exec.
if let Some(exec) = app.pending_exec.take() {
run_exec(terminal, exec).await?;