french-wiktionary-flashcards

Easily create Anki flashcards from Wiktionary data.
Log | Files | Refs | README

commit 33f13eb1b0fff7872765282e4174ab2f83868ef0
parent 66c3a81957a43819576b10b4f6221a827419b91e
Author: David Schlachter <t480-debian-git@schlachter.ca>
Date:   Sun,  4 Oct 2026 01:45:03 -0400

Improve raw dictionary check

Diffstat:
Mmain.go | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/main.go b/main.go @@ -51,11 +51,16 @@ func main() { if *dict == "" { log.Fatal("The -dictionary flag cannot be empty. (Defaults to dictionary.sqlite3.)") } - if *rawDict == "" { - log.Fatal("The -rawDictionary flag cannot be empty. (Defaults to raw-wiktextract-data.jsonl.)") - } else if *rawDict == "raw-wiktextract-data.jsonl" { - if _, err := os.Stat("./raw-wiktextract-data.jsonl"); errors.Is(err, os.ErrNotExist) { - log.Fatal("Could not find raw dictionary data file! You can get this by downloading and gunzipping https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz.") + + if *rawDict == "raw-wiktextract-data.jsonl" { + // Check if we have a sqlite dictionary first + if _, err := os.Stat(*dict); errors.Is(err, os.ErrNotExist) { + // If we don't have a sqlite3 dictionary, that's okay, but, we're + // going to have to read the rawDictionary in order to create it. + // So, make sure that it exists! + if _, err := os.Stat("./raw-wiktextract-data.jsonl"); errors.Is(err, os.ErrNotExist) { + log.Fatal("Could not find raw dictionary data file! You can get this by downloading and gunzipping https://kaikki.org/frwiktionary/raw-wiktextract-data.jsonl.gz.") + } } } if *deckName == "" {