From a126fba82cb4f9f4467b130fca7fd5a269fe3a5e Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 13 Oct 2024 15:15:55 +0200 Subject: Show sync error as TUI --- src/main.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index b18cb1a..ebc2d7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,27 +27,33 @@ fn main() -> Result<()> { let deck_path = args.deck; let mut conn = db::init(db_path(&deck_path))?; let deck_name = deck::pp_from_path(&deck_path).unwrap_or_else(|| "Deck".to_string()); - - sync::run(&mut conn, &deck_path)?; - let deck_last_sync = util::time::seconds_since_unix_epoch()?; - let mut term = gui::setup_terminal()?; - match gui::start( - &mut conn, - &mut term, - &deck_path, - &deck_name, - deck_last_sync, - args.hide_remaining, - ) { - Ok(()) => (), + match sync::run(&mut conn, &deck_path) { + Ok(()) => { + let deck_last_sync = util::time::seconds_since_unix_epoch()?; + + match gui::start( + &mut conn, + &mut term, + &deck_path, + &deck_name, + deck_last_sync, + args.hide_remaining, + ) { + Ok(()) => (), + Err(msg) => { + // Show errors in TUI, otherwise they are hidden + gui::message::show(&mut term, &deck_name, &format!("{msg}"), true)? + } + } + }, Err(msg) => { - // Show errors in TUI, otherwise they are hidden gui::message::show(&mut term, &deck_name, &format!("{msg}"), true)? } } + gui::restore_terminal(&mut term) } -- cgit v1.2.3