aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2022-02-06 19:47:09 +0100
committerJoris2022-02-06 19:47:09 +0100
commit3b6ceec4c5425d2741af7bff1fdad385f04e250f (patch)
treebd20cd863779aca8dee6c351916bfd5d32ba0e19 /src
parent37f646c9908e0ebb5077874fcd0e93b1bbde0694 (diff)
Ask only for the deck path
Derive the DB path from the deck path.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs18
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()
+}