diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:02:49 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-27 14:02:49 +0200 |
| commit | 78825639eab3c84d84a60fbd1f1781bcfa332044 (patch) | |
| tree | 75135a3e67d263a048470198e12e4573dc59e63a /internal/cli | |
| parent | 58b748340059a02e696f6a7168f81114ac0f99e9 (diff) | |
| download | lectio-78825639eab3c84d84a60fbd1f1781bcfa332044.tar.gz lectio-78825639eab3c84d84a60fbd1f1781bcfa332044.zip | |
feat(caldata,cli): embed 1962 EF calendar + form-aware Stack; --liturgy computes EF
caldata.Tridentine()/Base(form); Stack(form,dir,use); runLiturgy drops the EF
guard and uses the form's base; rankLabel shows I-IV class; display omits OF
cycles + strips ef- slug prefix for EF.
Diffstat (limited to 'internal/cli')
| -rw-r--r-- | internal/cli/liturgy.go | 30 | ||||
| -rw-r--r-- | internal/cli/liturgy_test.go | 15 |
2 files changed, 28 insertions, 17 deletions
diff --git a/internal/cli/liturgy.go b/internal/cli/liturgy.go index 24052ab..b1a8874 100644 --- a/internal/cli/liturgy.go +++ b/internal/cli/liturgy.go @@ -23,16 +23,8 @@ func runLiturgy(cfg config.Config, date string, stdout, stderr io.Writer) int { fmt.Fprintf(stderr, "lectio: bad date %q (want YYYY-MM-DD)\n", date) return 2 } - // The computed engine currently does the Ordinary Form only. Rather than - // silently return OF for a traditional (EF) config, say so. - if cfg.Selection().Form == "old" { - fmt.Fprintln(stderr, "lectio: the offline calendar engine currently computes only the Ordinary Form.") - fmt.Fprintln(stderr, " Traditional (1962 EF) computation is not built yet; your traditional daily") - fmt.Fprintln(stderr, " readings still work via 'lectio [DATE]'. To compute the OF: add --lectionary new.") - return 1 - } dir, _ := config.CalendarsDir() - layers, errs := caldata.Stack(dir, cfg.Use) + layers, errs := caldata.Stack(cfg.Selection().Form, dir, cfg.Use) for _, e := range errs { fmt.Fprintln(stderr, "lectio: warning:", e) } @@ -43,8 +35,12 @@ func runLiturgy(cfg config.Config, date string, stdout, stderr io.Writer) int { func printLiturgicalDay(out io.Writer, cfg config.Config, day calendar.LiturgicalDay) { fmt.Fprintf(out, "%s %s\n", day.Date.Format("2006-01-02"), day.Weekday.String()) - fmt.Fprintf(out, "season: %s (week %d · Sunday cycle %s · weekday cycle %s)\n", - day.Season, day.Week, day.SundayCycle, day.WeekdayCycle) + if day.SundayCycle != "" { // OF carries the reading cycles; EF does not + fmt.Fprintf(out, "season: %s (week %d · Sunday cycle %s · weekday cycle %s)\n", + day.Season, day.Week, day.SundayCycle, day.WeekdayCycle) + } else { + fmt.Fprintf(out, "season: %s (week %d)\n", day.Season, day.Week) + } fmt.Fprintf(out, "observed: %s [%s · %s]\n", celebrationName(cfg, day.Observed), rankLabel(day.Observed.Rank), day.Colour) for _, o := range day.Others { if n := celebrationName(cfg, o); n != "" { @@ -78,7 +74,7 @@ func celebrationName(cfg config.Config, c calendar.Celebration) string { if c.Slug == "" { return "(feria)" } - return strings.ReplaceAll(c.Slug, "-", " ") + return strings.ReplaceAll(strings.TrimPrefix(c.Slug, "ef-"), "-", " ") } func rankLabel(r calendar.Rank) string { @@ -91,6 +87,16 @@ func rankLabel(r calendar.Rank) string { return "memorial" case calendar.RankOptional: return "optional memorial" + case calendar.RankClass1: + return "I class" + case calendar.RankClass2: + return "II class" + case calendar.RankClass3: + return "III class" + case calendar.RankClass4: + return "IV class" + case calendar.RankCommemoration: + return "commemoration" default: return "feria" } diff --git a/internal/cli/liturgy_test.go b/internal/cli/liturgy_test.go index 02f02c4..c9d66a5 100644 --- a/internal/cli/liturgy_test.go +++ b/internal/cli/liturgy_test.go @@ -33,7 +33,7 @@ func TestRunLiturgy(t *testing.T) { } } -func TestRunLiturgyTraditionalGuarded(t *testing.T) { +func TestRunLiturgyTraditionalComputesEF(t *testing.T) { dir := t.TempDir() t.Setenv("LECTIO_CONFIG", filepath.Join(dir, "config.ini")) os.WriteFile(filepath.Join(dir, "config.ini"), []byte("lectionary = traditional\n"), 0o644) @@ -42,11 +42,16 @@ func TestRunLiturgyTraditionalGuarded(t *testing.T) { t.Fatal(err) } var buf bytes.Buffer - if code := runLiturgy(cfg, "2025-08-15", &buf, &buf); code == 0 { - t.Fatalf("traditional config should be guarded, not computed as OF:\n%s", buf.String()) + if code := runLiturgy(cfg, "2025-08-15", &buf, &buf); code != 0 { + t.Fatalf("EF compute failed (%d):\n%s", code, buf.String()) + } + out := buf.String() + // EF: Assumption is I class, and 2025-08-15 is in Time after Pentecost (not OF "ordinary"). + if !strings.Contains(out, "Assumption") || !strings.Contains(out, "I class") { + t.Errorf("expected EF Assumption (I class):\n%s", out) } - if !strings.Contains(strings.ToLower(buf.String()), "ordinary form") { - t.Errorf("expected an EF-not-implemented notice:\n%s", buf.String()) + if !strings.Contains(out, "time-after-pentecost") { + t.Errorf("expected EF season time-after-pentecost:\n%s", out) } } |
