From 0db24ba21a67c99d79d321fc82391e13656c40e4 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 29 Jul 2026 09:55:22 +0200 Subject: feat(clectio-gen): apply a calendar layer/sanctorale when generating Add opt-in flags so clectio's tables can be regenerated from a customized calendar instead of only the embedded universal one: clectio-gen -caldir DIR -use a,b [-sanctorale DIR] y0 y1 out/ - -caldir + -use stack calendar layers (rank, colour, name, reading.*) over the calendar; -sanctorale DIR applies a full of.ini/ef.ini replacement. - The BOOK table stays hermetic (LECTIO_CONFIG still points nowhere), so the generator can't read a stale user books.ini -- calendar customization and the book aliases are kept separate concerns. - config.SetCalendarsDir lets CalendarsDir be pointed at an explicit layer dir without a full config tree (and without an unrelated books.ini there). Verified end to end: a layer adding a feast with a proper gospel regenerates into liturgy_of.h + verses_of.keys, and the rebuilt clectio shows it. Default (no flags) output is byte-identical to before. make test green. --- internal/config/config.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/config/config.go b/internal/config/config.go index a225a12..cd32c90 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -324,9 +324,22 @@ func configPath() (path string, isDefault bool, err error) { return filepath.Join(dir, "lectio", "config.ini"), true, nil } +// calendarsDirOverride, when set, is returned by CalendarsDir verbatim, +// bypassing the config-relative default. It lets a tool (e.g. clectio-gen) apply +// calendar layers from an explicit directory without pointing the whole config +// tree -- and without picking up an unrelated books.ini -- at that location. +var calendarsDirOverride string + +// SetCalendarsDir overrides the directory CalendarsDir returns. Empty (the +// default) restores the config-relative /calendars. +func SetCalendarsDir(dir string) { calendarsDirOverride = dir } + // CalendarsDir returns the directory holding user calendar-layer files -// (/calendars). +// (/calendars, unless overridden by SetCalendarsDir). func CalendarsDir() (string, error) { + if calendarsDirOverride != "" { + return calendarsDirOverride, nil + } p, _, err := configPath() if err != nil { return "", err -- cgit v1.3