diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index f9d2288..9720370 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,21 +7,25 @@ mod util; use anyhow::Result; use structopt::StructOpt; +use std::path::PathBuf; #[derive(StructOpt)] #[structopt()] struct Opt { - #[structopt(long, default_value = "database.db")] - database: String, - - #[structopt(long, default_value = "deck.deck")] + #[structopt(long, default_value = "deck")] deck: String, } fn main() -> Result<()> { - let opt = Opt::from_args(); - let conn = db::db::init(opt.database)?; - let entries = deck::read(opt.deck)?; + 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() +} |