diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index bed2ce1..c2373f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ mod util; use crate::util::event::Events; use anyhow::Result; +use rusqlite::Connection; use std::path::PathBuf; use structopt::StructOpt; @@ -23,8 +24,25 @@ fn main() -> Result<()> { let deck_name = deck::pp_from_path(&deck_path).unwrap_or_else(|| "Deck".to_string()); let mut term = gui::terminal()?; let events = Events::new(); - gui::synchronize(&conn, &mut term, &events, &deck_path, &deck_name)?; - gui::start(&conn, &mut term, &events, &deck_name) + match run_tui(conn, &deck_path, &deck_name, &mut term, &events) { + Ok(()) => Ok(()), + Err(msg) => { + // Show errors in TUI, otherwise they are hidden + gui::message::show(&mut term, &events, &deck_name, &format!("{}", msg), true)?; + Err(msg) + } + } +} + +fn run_tui( + conn: Connection, + deck_path: &str, + deck_name: &str, + term: &mut gui::Term, + events: &Events, +) -> Result<()> { + gui::synchronize(&conn, term, &events, &deck_path, &deck_name)?; + gui::start(&conn, term, &events, &deck_name) } fn db_path(deck_path: &str) -> String { |