aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-29 09:55:22 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-29 09:55:22 +0200
commit0db24ba21a67c99d79d321fc82391e13656c40e4 (patch)
treefc52c9130a7b54d811cd1c61bc5d7f4fb180cacc /internal
parent4ef5570c348e2d8d83c67e049b06e7b5d1a7542d (diff)
downloadlectio-0db24ba21a67c99d79d321fc82391e13656c40e4.tar.gz
lectio-0db24ba21a67c99d79d321fc82391e13656c40e4.zip
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] <new|old> 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.
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go15
1 files changed, 14 insertions, 1 deletions
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 <config dir>/calendars.
+func SetCalendarsDir(dir string) { calendarsDirOverride = dir }
+
// CalendarsDir returns the directory holding user calendar-layer files
-// (<config dir>/calendars).
+// (<config dir>/calendars, unless overridden by SetCalendarsDir).
func CalendarsDir() (string, error) {
+ if calendarsDirOverride != "" {
+ return calendarsDirOverride, nil
+ }
p, _, err := configPath()
if err != nil {
return "", err