diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:52:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:52:13 +0200 |
| commit | 44472bbe31475a3c672ae003d928d7caffb4b50a (patch) | |
| tree | e74bae03c61b62479ef4f68b046e3345618933c8 /internal/cli/cli.go | |
| parent | 626f2275438a37e5cd2efb5964281b9bef5ce8cc (diff) | |
| parent | 7b220084cf3951c8cde0582efdfcf628afc64336 (diff) | |
| download | lectio-44472bbe31475a3c672ae003d928d7caffb4b50a.tar.gz lectio-44472bbe31475a3c672ae003d928d7caffb4b50a.zip | |
Merge branch 'of-offline-migration': offline daily view, remove scrapers
Diffstat (limited to 'internal/cli/cli.go')
| -rw-r--r-- | internal/cli/cli.go | 286 |
1 files changed, 64 insertions, 222 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go index f65774f..c4f063d 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -1,6 +1,6 @@ // Package cli is lectio's flag-driven command dispatcher: it wires config, -// the readings router, liturgy.Harvest and render together into the -// `lectio` binary's Run entry point. +// the offline readings engine and render together into the `lectio` binary's +// Run entry point. package cli import ( @@ -21,7 +21,6 @@ import ( "github.com/lukaszkasprzak/lectio/internal/liturgy" "github.com/lukaszkasprzak/lectio/internal/readings" "github.com/lukaszkasprzak/lectio/internal/render" - "github.com/lukaszkasprzak/lectio/internal/tradlit" ) const helpText = `lectio — daily Catholic liturgy readings (Polish + 4 versions) @@ -31,18 +30,13 @@ Usage: Flags: -a, --all all readings, not just the gospel - -b, --bible VER one version's text: bt,wuj,vul,grb,drb + -b, --bible VER one version's text: wuj,vul,grb,drb -c, --compare LIST versions side by side (comma-separated) -p, --ref REF look up a passage (e.g. "J 3:16") with -b/-c -r, --raw text only, no banner/headings (for piping) -w, --width N wrap width; 0 = detect terminal - -R, --refresh ignore cache, re-download - -o, --offline cache/sigla only, no network -l, --lectionary WHICH new|trad (trad -> traditional) - -g, --lang LANG traditional lectionary language: pl|en --ui-lang LANG override interface/export language: pl|en - -u, --update harvest sigla maximally to the horizon (idempotent) - -C, --clean prune cached readings older than a year -P, --pager page reading output (like git); default from config --no-pager never page, even if config sets one --list list all books + abbreviations (dialect from sigla_style) @@ -54,8 +48,7 @@ Flags: --corpus-check X validate a bible corpus (code, e.g. drb, or a path to a <code>.tsv) and exit; errors fail, coverage gaps warn --json with --corpus-check, print the report as JSON - --rand, --rand-v print a random verse and exit (uses default_version or -b VER; - bt has no corpus, so it falls back to a corpus version) + --rand, --rand-v print a random verse and exit (uses default_version or -b VER) --rand-ch print a random chapter and exit --md export the readings as Markdown (to --out or stdout) --pdf export the readings as PDF (to --out or stdout) @@ -69,16 +62,14 @@ Flags: -v, --version print the version and exit -h, --help this help -Versions: bt (Biblia Tysiąclecia) wuj (Wujek) vul (Wulgata) grb (Grecki) - drb (Douay-Rheims) +Versions: wuj (Wujek) vul (Wulgata) grb (Grecki) drb (Douay-Rheims) Examples: lectio today's gospel lectio 2026-07-22 -a all readings for a date - lectio -c bt,wuj 2026-07-22 compare two versions for a date + lectio -c wuj,drb 2026-07-22 compare two versions for a date lectio -b vul -a Vulgate text, all readings lectio -l trad -a traditional lectionary, all readings - lectio -u harvest sigla to the horizon lectio -p "Jn 3:16" -b vul look up a passage (English sigla) lectio -p "J 3,16" -c wuj,drb Polish sigla when sigla_style=polish/auto+pl UI lectio --list list every book + abbreviations @@ -86,8 +77,8 @@ Examples: lectio --week 2026-07-22 a week of gospel references from a date lectio --rand-v a random verse (for cron/prompt) -Flags override config. Exit codes: 0 ok, 1 runtime error (fetch/parse), -2 usage error (bad flag, bad date, bad version, bad --lectionary/--lang). +Flags override config. Exit codes: 0 ok, 1 runtime error, 2 usage error +(bad flag, bad date, bad version, bad --lectionary). ` const ( @@ -122,11 +113,11 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { return 2 } - var all, raw, refresh, offline, update, clean, pagerFlag, noPager, citation, week bool + var all, raw, pagerFlag, noPager, citation, week bool var randV, randCh bool var expMD, expPDF bool var output, calendar, uiLang string - var bibleVer, compareList, lectionary, lang string + var bibleVer, compareList, lectionary string var width int var list bool var ref string @@ -142,27 +133,17 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { fs.BoolVar(&all, "a", false, "all readings, not just the gospel") fs.BoolVar(&all, "all", false, "all readings, not just the gospel") - fs.StringVar(&bibleVer, "b", "", "one version's text: bt,wuj,vul,grb,drb") - fs.StringVar(&bibleVer, "bible", "", "one version's text: bt,wuj,vul,grb,drb") + fs.StringVar(&bibleVer, "b", "", "one version's text: wuj,vul,grb,drb") + fs.StringVar(&bibleVer, "bible", "", "one version's text: wuj,vul,grb,drb") fs.StringVar(&compareList, "c", "", "versions side by side (comma list)") fs.StringVar(&compareList, "compare", "", "versions side by side (comma list)") fs.BoolVar(&raw, "r", false, "text only, no banner/headings") fs.BoolVar(&raw, "raw", false, "text only, no banner/headings") fs.IntVar(&width, "w", 0, "wrap width (0 = detect terminal)") fs.IntVar(&width, "width", 0, "wrap width (0 = detect terminal)") - fs.BoolVar(&refresh, "R", false, "ignore cache, re-download") - fs.BoolVar(&refresh, "refresh", false, "ignore cache, re-download") - fs.BoolVar(&offline, "o", false, "cache/sigla only, no network") - fs.BoolVar(&offline, "offline", false, "cache/sigla only, no network") fs.StringVar(&lectionary, "l", "", "new|trad") fs.StringVar(&lectionary, "lectionary", "", "new|trad") - fs.StringVar(&lang, "g", "", "pl|en") - fs.StringVar(&lang, "lang", "", "pl|en") fs.StringVar(&uiLang, "ui-lang", "", "override interface/export language: pl|en") - fs.BoolVar(&update, "u", false, "harvest sigla maximally to the horizon") - fs.BoolVar(&update, "update", false, "harvest sigla maximally to the horizon") - fs.BoolVar(&clean, "C", false, "prune cached readings older than a year") - fs.BoolVar(&clean, "clean", false, "prune cached readings older than a year") fs.BoolVar(&pagerFlag, "P", false, "page reading output (like git)") fs.BoolVar(&pagerFlag, "pager", false, "page reading output (like git)") fs.BoolVar(&noPager, "no-pager", false, "never page, even if config sets one") @@ -204,17 +185,6 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { fmt.Fprintln(stderr, "lectio:", err) return 2 } - if lang != "" && lang != "pl" && lang != "en" { - fmt.Fprintf(stderr, "lectio: invalid --lang %q (want pl|en)\n", lang) - return 2 - } - - if clean { - return runClean(stdout, stderr) - } - if update { - return runHarvest(date, stdout, stderr) - } if calNew != "" { return runCalNew(calNew, stdout, stderr) } @@ -233,15 +203,9 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { if dir, err := config.CorporaDir(); err == nil { bible.SetUserCorporaDir(dir) } - if offline { - cfg.Offline = true - } if lectionary != "" { cfg.Lectionary = lectionary } - if lang != "" { - cfg.TraditionalLang = lang - } if uiLang != "" { cfg.UILanguage = config.NormalizeUILanguage(uiLang) } @@ -265,9 +229,9 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { } return runRand(cfg, tbl, ver, randCh, raw, width, stdout, stderr) case citation: - return runCitation(cfg, tbl, date, refresh, stdout, stderr) + return runCitation(cfg, tbl, date, stdout, stderr) default: - return runWeek(cfg, tbl, date, refresh, stdout, stderr) + return runWeek(cfg, tbl, date, stdout, stderr) } } @@ -279,10 +243,10 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { ver = cfg.DefaultVersion } if !config.ValidVersion(ver) { - fmt.Fprintf(stderr, "lectio: unknown version %q (want one of bt, wuj, vul, grb, drb)\n", ver) + fmt.Fprintf(stderr, "lectio: unknown version %q (want one of wuj, vul, grb, drb)\n", ver) return 2 } - return runExport(cfg, date, ver, effAll, refresh, expPDF, output, stdout, stderr) + return runExport(cfg, date, ver, effAll, expPDF, output, stdout, stderr) } if calendar != "" { return runCalendar(cfg, calendar, output, stdout, stderr) @@ -313,13 +277,13 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { // Day-reading paths: bt is a valid version here (compareList wins over // bibleVer, as before, so bibleVer is left unvalidated when a list is given). if bibleVer != "" && compareList == "" && !config.ValidVersion(bibleVer) { - fmt.Fprintf(stderr, "lectio: unknown version %q (want one of bt, wuj, vul, grb, drb)\n", bibleVer) + fmt.Fprintf(stderr, "lectio: unknown version %q (want one of wuj, vul, grb, drb)\n", bibleVer) return 2 } if compareList != "" { for _, v := range strings.Split(compareList, ",") { if v = strings.TrimSpace(v); v != "" && !config.ValidVersion(v) { - fmt.Fprintf(stderr, "lectio: unknown version %q (want one of bt, wuj, vul, grb, drb)\n", v) + fmt.Fprintf(stderr, "lectio: unknown version %q (want one of wuj, vul, grb, drb)\n", v) return 2 } } @@ -351,11 +315,11 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int { case ref != "": code = lookupRef(cfg, bookTbl, ref, refVersions, raw, effWidth, out, stderr) case compareList != "": - code = renderCompare(cfg, compareList, date, effAll, raw, effWidth, refresh, out, stderr) + code = renderCompare(cfg, compareList, date, effAll, raw, effWidth, out, stderr) case bibleVer != "": - code = fetchAndPrint(cfg, bibleVer, date, effAll, raw, effWidth, refresh, out, stderr) + code = fetchAndPrint(cfg, bibleVer, date, effAll, raw, effWidth, out, stderr) default: - code = fetchAndPrint(cfg, cfg.DefaultVersion, date, effAll, raw, effWidth, refresh, out, stderr) + code = fetchAndPrint(cfg, cfg.DefaultVersion, date, effAll, raw, effWidth, out, stderr) } finish() return code @@ -389,34 +353,19 @@ func gospelCitation(sec liturgy.Section) string { return "" } -// dialectCitation renders a gospel section's reference in the configured sigla -// dialect (cfg.SiglaLang(): sigla_style, or -- "auto" -- ui_language). The -// source citation's language is the lectionary's: Polish for the modern -// (niedziela) lectionary, cfg.TraditionalLang for the traditional one. The ref -// is parsed to canonical and re-rendered in the target dialect; a citation -// whose book can't be parsed comes back in its source form unchanged. +// dialectCitation returns a gospel section's reference for display. The offline +// loader already renders Section.Citation in the reader's configured sigla +// dialect (see readings.citationForms), so this just returns it (cfg and tbl are +// kept for signature compatibility with the callers). func dialectCitation(cfg config.Config, tbl *bible.BookTable, sec liturgy.Section) string { - raw := gospelCitation(sec) - if raw == "" || tbl == nil { - return raw - } - sourceLang := "pl" - if cfg.Lectionary == "traditional" { - sourceLang = cfg.TraditionalLang - } - canonical, ok := tbl.ParseRef(sourceLang, raw) - if !ok { - return raw - } - return tbl.FormatRef(cfg.SiglaLang(), canonical) + return gospelCitation(sec) } -// runExport handles --md/--pdf: load the day's readings and write them as -// Markdown or PDF to --out FILE (or stdout). Honors date/lectionary/all/offline -// and the version (bt is fine -- it is the niedziela text -- but is swapped for -// traditional/offline via EffectiveVersions). -func runExport(cfg config.Config, date, version string, all, refresh, asPDF bool, output string, stdout, stderr io.Writer) int { - secs, info, err := readings.Load(cfg, readings.Options{Date: date, Refresh: refresh, Offline: cfg.Offline, All: all}) +// runExport handles --md/--pdf: compute the day's readings offline and write +// them as Markdown or PDF to --out FILE (or stdout). Honors date/lectionary/all +// and the version. +func runExport(cfg config.Config, date, version string, all, asPDF bool, output string, stdout, stderr io.Writer) int { + secs, info, err := readings.Load(cfg, readings.Options{Date: date, All: all}) if err != nil { fmt.Fprintln(stderr, "lectio:", err) return 1 @@ -425,8 +374,8 @@ func runExport(cfg config.Config, date, version string, all, refresh, asPDF bool fmt.Fprintln(stderr, "lectio: no readings found for", date) return 1 } - if vs := render.EffectiveVersions([]string{version}, cfg.Lectionary, cfg.Offline); len(vs) > 0 { - version = vs[0] + if version == "" || version == "bt" { + version = vernacularVersion(cfg) } var data []byte @@ -466,7 +415,7 @@ func runCalendar(cfg config.Config, ym, output string, stdout, stderr io.Writer) var days []export.CalendarDay for d := first; int(d.Month()) == month; d = d.AddDate(0, 0, 1) { cd := export.CalendarDay{Day: d.Day()} - if secs, info, lerr := readings.Load(cfg, readings.Options{Date: d.Format("2006-01-02"), Offline: cfg.Offline, All: false}); lerr == nil { + if secs, info, lerr := readings.Load(cfg, readings.Options{Date: d.Format("2006-01-02"), All: false}); lerr == nil { cd.Name = info.Name cd.Colour = info.Colour cd.Citation = readings.GospelCitation(secs) @@ -495,8 +444,8 @@ func runCalendar(cfg config.Config, ym, output string, stdout, stderr io.Writer) // dialectCitation), for scripts/cron/prompt use. Honors the resolved cfg // (lectionary/lang/offline) and date. Exit 1 if the day has no gospel // reference (unpublished date, no network while offline, ...). -func runCitation(cfg config.Config, tbl *bible.BookTable, date string, refresh bool, stdout, stderr io.Writer) int { - secs, _, err := readings.Load(cfg, readings.Options{Date: date, Refresh: refresh, Offline: cfg.Offline, All: false}) +func runCitation(cfg config.Config, tbl *bible.BookTable, date string, stdout, stderr io.Writer) int { + secs, _, err := readings.Load(cfg, readings.Options{Date: date, All: false}) if err != nil { fmt.Fprintln(stderr, "lectio:", err) return 1 @@ -520,7 +469,7 @@ func runCitation(cfg config.Config, tbl *bible.BookTable, date string, refresh b // can't be loaded (unpublished, offline gap, no gospel) shows "—" rather than // aborting the run, so the list is always seven lines. Honors cfg // (lectionary/lang/offline). -func runWeek(cfg config.Config, tbl *bible.BookTable, date string, refresh bool, stdout, stderr io.Writer) int { +func runWeek(cfg config.Config, tbl *bible.BookTable, date string, stdout, stderr io.Writer) int { start, err := time.Parse("2006-01-02", date) if err != nil { fmt.Fprintln(stderr, "lectio:", err) @@ -529,7 +478,7 @@ func runWeek(cfg config.Config, tbl *bible.BookTable, date string, refresh bool, for i := 0; i < 7; i++ { d := start.AddDate(0, 0, i).Format("2006-01-02") cit := "—" - secs, _, err := readings.Load(cfg, readings.Options{Date: d, Refresh: refresh, Offline: cfg.Offline, All: false}) + secs, _, err := readings.Load(cfg, readings.Options{Date: d, All: false}) if err == nil { if sec, ok := gospelSection(secs); ok { if c := dialectCitation(cfg, tbl, sec); c != "" { @@ -628,116 +577,11 @@ func normalizeLectionary(lectionary string) (string, error) { return v, nil } -// runHarvest handles -u/--update: harvest sigla maximally (to the -// unpublished horizon) from date for the modern lectionary, printing the -// outcome or -- on a genuine interruption (see liturgy.Harvest) -- the -// error. On a successful harvest it also best-effort pre-caches the -// traditional lectionary's propers (internal/tradlit) for every date in -// that same [date, furthest] window, so 'lectio update' prepares both -// lectionaries for offline use in one run. The 1962 calendar has no -// "unpublished horizon" (every date has propers), so this is a plain -// date-range fetch; a per-date failure is not fatal here -- it never -// prevented the traditional lectionary from working live before, and the -// modern-harvest outcome is still reported either way. -func runHarvest(date string, stdout, stderr io.Writer) int { - added, furthest, err := liturgy.Harvest(date, 0) - if err != nil { - fmt.Fprintln(stderr, "lectio:", err) - return 1 - } - - lang := config.Default().TraditionalLang - cachedTrad := 0 - if furthest != "" { - if cfg, cfgErr := config.Load(); cfgErr == nil { - lang = cfg.TraditionalLang - cachedTrad = cacheTraditionalRange(date, furthest, lang) - } - } - - fmt.Fprintf(stdout, "harvested %d day(s), furthest %s; cached traditional propers (%s) for %d day(s)\n", - added, furthest, lang, cachedTrad) - return 0 -} - -// cacheTraditionalRange best-effort pre-caches tradlit's traditional propers -// for lang for every date in [from, to] inclusive (walking forward a day at -// a time), returning how many dates succeeded. A per-date failure (e.g. a -// transient network hiccup) is ignored -- the traditional 1962 calendar has -// propers for every date, so there is no "unpublished horizon" to stop at -// the way liturgy.Harvest has for the modern lectionary. -func cacheTraditionalRange(from, to, lang string) int { - start, err := time.Parse("2006-01-02", from) - if err != nil { - return 0 - } - end, err := time.Parse("2006-01-02", to) - if err != nil { - return 0 - } - - cached := 0 - for d := start; !d.After(end); d = d.AddDate(0, 0, 1) { - if _, _, err := tradlit.Load(d.Format("2006-01-02"), lang, false); err == nil { - cached++ - } - } - return cached -} - -// runClean handles -C/--clean: prune cached readings older than one year -// (relative to today()) and print a human-readable summary of what was -// removed. Like -u/--update, this is a maintenance mode -- it ignores DATE -// and every render flag, and is dispatched before the render paths. If both -// --clean and -u/--update are given, --clean takes precedence (see Run). -func runClean(stdout, stderr io.Writer) int { - now, err := time.Parse("2006-01-02", today()) - if err != nil { - fmt.Fprintln(stderr, "lectio:", err) - return 1 - } - before := now.AddDate(-1, 0, 0) - - removed, freed, err := liturgy.CleanCache(before) - if err != nil { - fmt.Fprintln(stderr, "lectio:", err) - return 1 - } - - cutoff := before.Format("2006-01-02") - if removed == 0 { - fmt.Fprintf(stdout, "cache already clean (nothing older than %s)\n", cutoff) - return 0 - } - entries := "entries" - if removed == 1 { - entries = "entry" - } - fmt.Fprintf(stdout, "cleaned %d cache %s older than %s (freed %s)\n", removed, entries, cutoff, formatFreed(freed)) - return 0 -} - -// formatFreed renders a byte count the way -C/--clean's summary line wants -// it: megabytes with one decimal once it's a meaningful size, kilobytes -// (also one decimal) for anything smaller. -func formatFreed(bytes int64) string { - const mb = 1024 * 1024 - if bytes >= mb { - return fmt.Sprintf("%.1f MB", float64(bytes)/mb) - } - return fmt.Sprintf("%.1f KB", float64(bytes)/1024) -} - // fetchAndPrint is the shared single-version render path (default version or -// -b/--bible): fetch via the readings router, apply the offline version -// swap, then render each section's heading and render.GatherVersion blocks. -func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width int, refresh bool, stdout, stderr io.Writer) int { - secs, dayInfo, err := readings.Load(cfg, readings.Options{ - Date: date, - Refresh: refresh, - Offline: cfg.Offline, - All: all, - }) +// -b/--bible): compute the day's readings offline, resolve the reading corpus, +// then render each section's heading and render.GatherVersion blocks. +func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width int, stdout, stderr io.Writer) int { + secs, dayInfo, err := readings.Load(cfg, readings.Options{Date: date, All: all}) if err != nil { fmt.Fprintln(stderr, "lectio:", err) return 1 @@ -747,8 +591,12 @@ func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width return 1 } - if vs := render.EffectiveVersions([]string{version}, cfg.Lectionary, cfg.Offline); len(vs) > 0 { - version = vs[0] + // The single-version daily view renders lectio's own reading corpus (an + // explicit reading_version, else the vernacular that matches the UI + // language, else the complete Latin Vulgate -- the same choice -L makes), + // so the former "bt" niedziela default now maps to a real, offline corpus. + if version == "" || version == "bt" { + version = vernacularVersion(cfg) } w := resolveWidth(width, false, stdout) @@ -829,7 +677,7 @@ func renderSection(sec liturgy.Section, version, lectionary, lang string, width // renderCompare handles -c/--compare LIST: LIST is a comma-separated list of // version codes (falling back to cfg.Versions when empty), rendered side by // side via render.Compare. -func renderCompare(cfg config.Config, list, date string, all, raw bool, width int, refresh bool, stdout, stderr io.Writer) int { +func renderCompare(cfg config.Config, list, date string, all, raw bool, width int, stdout, stderr io.Writer) int { var versions []string if list == "" { versions = append(versions, cfg.Versions...) @@ -844,18 +692,13 @@ func renderCompare(cfg config.Config, list, date string, all, raw bool, width in } for _, v := range versions { if !config.ValidVersion(v) { - fmt.Fprintf(stderr, "lectio: unknown version %q (want one of bt, wuj, vul, grb, drb)\n", v) + fmt.Fprintf(stderr, "lectio: unknown version %q (want one of wuj, vul, grb, drb)\n", v) return 2 } } versions = render.EffectiveVersions(versions, cfg.Lectionary, cfg.Offline) - secs, dayInfo, err := readings.Load(cfg, readings.Options{ - Date: date, - Refresh: refresh, - Offline: cfg.Offline, - All: all, - }) + secs, dayInfo, err := readings.Load(cfg, readings.Options{Date: date, All: all}) if err != nil { fmt.Fprintln(stderr, "lectio:", err) return 1 @@ -879,18 +722,17 @@ func renderCompare(cfg config.Config, list, date string, all, raw bool, width in } // randVersion picks the corpus version for --rand: an explicit -b VER (any of -// the five is accepted), else the configured default_version. "bt" is allowed -// but has no embedded corpus (it is the niedziela.pl scrape), so it -- like an -// unset default -- transparently falls back to the first corpus version in -// cfg.Versions (else "wuj"), so --rand always yields a passage. Only an unknown -// version code is an error. +// the four is accepted), else the configured default_version. An unset default +// transparently falls back to the first corpus version in cfg.Versions (else +// "wuj"), so --rand always yields a passage. Only an unknown version code is an +// error. func randVersion(cfg config.Config, bibleVer string) (string, error) { v := bibleVer if v == "" { v = cfg.DefaultVersion } if v != "" && !config.ValidVersion(v) { - return "", fmt.Errorf("unknown version %q (want one of bt, wuj, vul, grb, drb)", v) + return "", fmt.Errorf("unknown version %q (want one of wuj, vul, grb, drb)", v) } if isCorpusVersion(v) { return v, nil @@ -959,14 +801,14 @@ func runRand(cfg config.Config, tbl *bible.BookTable, version string, chapter, r } // isCorpusVersion reports whether v is a scripture-text version with an -// embedded corpus (wuj/vul/grb/drb) -- i.e. a valid version that is not "bt" -// (the niedziela.pl scrape, which has no full text to look a passage up in). +// embedded corpus (wuj/vul/grb/drb) a passage can be looked up in. Every valid +// version now has a corpus, so this is exactly config.ValidVersion. func isCorpusVersion(v string) bool { - return config.ValidVersion(v) && v != "bt" + return config.ValidVersion(v) } // refLookupVersions resolves which corpus version(s) `--ref` should look a -// passage up in, rejecting "bt" (no corpus). Precedence: an explicit -c LIST, +// passage up in. Precedence: an explicit -c LIST, // then a single -b VER, then a sensible default (the configured default_version // if it has a corpus, else the first corpus version in cfg.Versions). It errors // (exit 2 in the caller) on any non-corpus version or if nothing usable is @@ -1009,10 +851,10 @@ func refLookupVersions(cfg config.Config, bibleVer, compareList string) ([]strin // in the resolved sigla dialect (bookTbl.ParseRef -- dialect-scoped book names // and number syntax) into an English colon-style reference, then reuses the // same render path as the readings with lectionary="traditional" (the ref is -// already in target form, looked up literally per version -- no niedziela -// conversion, no cross-version psalm renumbering). versions is the validated -// corpus set (never "bt"). raw omits the header. Exit 2 on an unparseable ref, -// exit 1 if no requested version has the passage. +// already in target form, looked up literally per version -- no cross-version +// psalm renumbering). versions is the validated corpus set. raw omits the +// header. Exit 2 on an unparseable ref, exit 1 if no requested version has the +// passage. func lookupRef(cfg config.Config, tbl *bible.BookTable, ref string, versions []string, raw bool, width int, stdout, stderr io.Writer) int { ref = strings.TrimSpace(ref) engRef, ok := tbl.ParseRef(cfg.SiglaLang(), ref) |
