From af1ac9b5fab2d05957d9b41a6c908a46cc90ae93 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Thu, 21 Aug 2025 00:18:26 +0100 Subject: [PATCH] Updated update and added an update script The --update flag accepts the file no rather than goes to download. Simpler. Better. Don't need the entire download.rs file now --- scryfall_deser/scripts/update_with_rofi.sh | 9 +++++++++ scryfall_deser/src/download.rs | 1 - scryfall_deser/src/main.rs | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100755 scryfall_deser/scripts/update_with_rofi.sh diff --git a/scryfall_deser/scripts/update_with_rofi.sh b/scryfall_deser/scripts/update_with_rofi.sh new file mode 100755 index 0000000..4e3bc3b --- /dev/null +++ b/scryfall_deser/scripts/update_with_rofi.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SCRYFALL_BULK=$(rofi -modi filebrowser -show filebrowser -filebrowser-command printf) +echo "$SCRYFALL_BULK" + +/home/arthurr/code/mini_projects/scryfall_deser/target/debug/scryfall_deser --update "$SCRYFALL_BULK" + +# TODO - check return value +rofi -e "Should be updated" diff --git a/scryfall_deser/src/download.rs b/scryfall_deser/src/download.rs index 8bc2135..21bd385 100644 --- a/scryfall_deser/src/download.rs +++ b/scryfall_deser/src/download.rs @@ -47,7 +47,6 @@ pub fn download_latest( stype: ScryfallBulkType, mut dest_file: &NamedTempFile, ) -> Result<(), Box> { - panic!(); let bulk_body: ScryfallBulk = ureq::get(SCRYFALL_BULK_API) .header("User-Agent", "Arthur's Card Finger Testing v0.1") .header("Accept", "application/json") diff --git a/scryfall_deser/src/main.rs b/scryfall_deser/src/main.rs index cfe306f..bc01378 100644 --- a/scryfall_deser/src/main.rs +++ b/scryfall_deser/src/main.rs @@ -31,9 +31,9 @@ enum MtgCardExit { #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Args { - /// Download the latest bulk from Scryfall and update local db + /// Update the local db from given Scryfall bulk download #[arg(short, long)] - update: bool, + update: Option, /// Search for the exact string #[arg(short, long)] exact: bool, @@ -69,11 +69,11 @@ fn _combine_search_strings(search_strings: Vec) -> String { fn main() -> MtgCardExit { let args = Args::parse(); - if args.update { + if let Some(update) = args.update { + dbg!(&update); init_db(); let mut path = get_local_cache_folder(); - // TODO - actually download the file - probably do away with TempFile stuff - path.push("oracle-cards-20250814210711.json"); + path.push(update); update_db_with_file(path); return MtgCardExit::Success; }