diff options
author | Joris | 2024-10-13 15:15:55 +0200 |
---|---|---|
committer | Joris | 2024-10-13 15:15:55 +0200 |
commit | a126fba82cb4f9f4467b130fca7fd5a269fe3a5e (patch) | |
tree | 1c9c5f73a059982d6f42a53a18e4ffe3487c9342 /src | |
parent | 049fc15b914c28749bfe399906865c7459d28772 (diff) |
Show sync error as TUI
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 34 |
1 files 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) } |