aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 972037056fe64423364e9212ba9edaef61533c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
mod db;
mod deck;
mod gui;
mod model;
mod space_repetition;
mod util;

use anyhow::Result;
use structopt::StructOpt;
use std::path::PathBuf;

#[derive(StructOpt)]
#[structopt()]
struct Opt {
    #[structopt(long, default_value = "deck")]
    deck: String,
}

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)?;
    gui::gui::start(&conn)
}

fn db_path(deck_path: &String) -> String {
    let mut path = PathBuf::from(deck_path);
    path.set_extension("db");
    path.to_string_lossy().to_string()
}