aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2022-01-29 12:21:17 +0100
committerJoris2022-01-29 12:21:17 +0100
commitdc0f32017cceabb6c683b6e1b4a2ae0248c37dbf (patch)
tree1d7f9a6217716c15147f82e61edc7e18e83af66c
parentfe0d0196f133bd902b176aa02119b7f2a49ebc35 (diff)
Read deck path from arguments as well
-rw-r--r--src/deck.rs4
-rw-r--r--src/main.rs7
2 files changed, 7 insertions, 4 deletions
diff --git a/src/deck.rs b/src/deck.rs
index 384ce19..0fe8a7b 100644
--- a/src/deck.rs
+++ b/src/deck.rs
@@ -23,8 +23,8 @@ impl std::error::Error for ParseError {
}
-pub fn read() -> Result<Vec<Entry>> {
- let file = File::open("deck")?;
+pub fn read(deck: String) -> Result<Vec<Entry>> {
+ let file = File::open(deck)?;
let reader = BufReader::new(file);
let mut entries: Vec<Entry> = Vec::new();
diff --git a/src/main.rs b/src/main.rs
index ef47c73..6ef241b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,14 +11,17 @@ use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt()]
struct Opt {
- #[structopt(short, long, default_value = "database.db")]
+ #[structopt(long, default_value = "database.db")]
database: String,
+
+ #[structopt(long, default_value = "deck.deck")]
+ deck: String,
}
fn main() -> Result<()> {
let opt = Opt::from_args();
let conn = db::db::init(opt.database)?;
- let entries = deck::read()?;
+ let entries = deck::read(opt.deck)?;
db::db::add_missing_deck_entries(&conn, entries)?;
gui::gui::start(&conn)
}