aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--src/main.rs18
2 files changed, 12 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index fb1b496..888222b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
target/
-deck
-database.db
+deck*
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()
+}