From dc0f32017cceabb6c683b6e1b4a2ae0248c37dbf Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 29 Jan 2022 12:21:17 +0100 Subject: Read deck path from arguments as well --- src/deck.rs | 4 ++-- src/main.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') 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> { - let file = File::open("deck")?; +pub fn read(deck: String) -> Result> { + let file = File::open(deck)?; let reader = BufReader::new(file); let mut entries: Vec = 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) } -- cgit v1.2.3