aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs34
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)
}