diff options
author | Joris | 2022-02-13 12:17:00 +0100 |
---|---|---|
committer | Joris | 2022-02-13 12:17:00 +0100 |
commit | 8a29f30fb2a949c03b318c4f7699136a8001be37 (patch) | |
tree | 51decc33aa776201bc800dc2196bc4f8b72337d7 /src/main.rs | |
parent | 8170fb5e432cc81986479a6a3a400e009426d76a (diff) | |
download | flashcards-8a29f30fb2a949c03b318c4f7699136a8001be37.tar.gz flashcards-8a29f30fb2a949c03b318c4f7699136a8001be37.tar.bz2 flashcards-8a29f30fb2a949c03b318c4f7699136a8001be37.zip |
Synchronize deck only if necessary
Look at the modification time of the deck, and synchronize if it has
been modified after the last deck read.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 44def4e..3e3e741 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod model; mod space_repetition; mod util; +use crate::util::event::Events; use anyhow::Result; use std::path::PathBuf; use structopt::StructOpt; @@ -17,12 +18,13 @@ struct Opt { } fn main() -> Result<()> { - let deck = Opt::from_args().deck; - let conn = db::db::init(db_path(&deck))?; - let entries = deck::read(&deck)?; - db::db::synchronize(&conn, entries)?; - let deck_name = deck::pp_from_path(&deck).unwrap_or("Deck".to_string()); - gui::gui::start(&conn, &deck_name) + let deck_path = Opt::from_args().deck; + let conn = db::db::init(db_path(&deck_path))?; + let deck_name = deck::pp_from_path(&deck_path).unwrap_or("Deck".to_string()); + let mut term = gui::gui::terminal()?; + let events = Events::new(); + gui::gui::synchronize(&conn, &mut term, &events, &deck_path, &deck_name)?; + gui::gui::start(&conn, &mut term, &events, &deck_name) } fn db_path(deck_path: &String) -> String { |