diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 09:55:22 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 09:55:22 +0200 |
| commit | 0db24ba21a67c99d79d321fc82391e13656c40e4 (patch) | |
| tree | fc52c9130a7b54d811cd1c61bc5d7f4fb180cacc /cmd/clectio-gen/main.go | |
| parent | 4ef5570c348e2d8d83c67e049b06e7b5d1a7542d (diff) | |
| download | lectio-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 'cmd/clectio-gen/main.go')
| -rw-r--r-- | cmd/clectio-gen/main.go | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/cmd/clectio-gen/main.go b/cmd/clectio-gen/main.go index 9a2930d..422cd34 100644 --- a/cmd/clectio-gen/main.go +++ b/cmd/clectio-gen/main.go @@ -12,11 +12,18 @@ // So the hard liturgical logic stays here (Go, oracle-validated); the C side is // a dumb lookup + renderer, and swapping the Bible never touches this generator. // -// Usage: clectio-gen <new|old> <startYear> <endYear> <outdir> +// Usage: clectio-gen [-caldir DIR -use NAMES] [-sanctorale DIR] <new|old> <startYear> <endYear> <outdir> +// +// By default it uses lectio's embedded, oracle-validated calendar. To bake a +// customized calendar into clectio, point it at calendar layers (-caldir with a +// comma-separated -use list) and/or a replacement sanctorale (-sanctorale DIR +// with of.ini/ef.ini). Only the calendar is taken from those; the book table +// stays embedded, so the generator never reads a stale user books.ini. package main import ( "bufio" + "flag" "fmt" "os" "path/filepath" @@ -25,6 +32,7 @@ import ( "time" "github.com/lukaszkasprzak/lectio/internal/bible" + "github.com/lukaszkasprzak/lectio/internal/caldata" "github.com/lukaszkasprzak/lectio/internal/config" "github.com/lukaszkasprzak/lectio/internal/liturgy" "github.com/lukaszkasprzak/lectio/internal/readings" @@ -92,30 +100,51 @@ type day struct { } func main() { - if len(os.Args) != 5 { - fmt.Fprintln(os.Stderr, "usage: clectio-gen <new|old> <startYear> <endYear> <outdir>") + caldir := flag.String("caldir", "", "directory of calendar-layer .ini files to apply (use with -use)") + use := flag.String("use", "", "comma-separated layer names to stack over the calendar (needs -caldir)") + sanctorale := flag.String("sanctorale", "", "directory with of.ini/ef.ini that REPLACE the embedded sanctorale") + flag.Usage = func() { + fmt.Fprintln(os.Stderr, "usage: clectio-gen [-caldir DIR -use NAMES] [-sanctorale DIR] <new|old> <startYear> <endYear> <outdir>") + flag.PrintDefaults() + } + flag.Parse() + args := flag.Args() + if len(args) != 4 { + flag.Usage() os.Exit(2) } - // Hermetic: point config at a nonexistent path so the generator always uses - // lectio's EMBEDDED calendar, lectionary and book table -- never the running - // user's ~/.config/lectio (whose books.ini/calendars/etc. could be stale and - // would silently change or drop readings). + // Hermetic BOOK table: point config at a nonexistent path so the generator + // never reads the running user's ~/.config/lectio/books.ini (which could be + // stale and silently drop readings). Calendar customization comes ONLY from + // the explicit flags below, so the two concerns stay separate. os.Setenv("LECTIO_CONFIG", filepath.Join(os.TempDir(), "clectio-gen-no-such-dir", "config.ini")) - form := os.Args[1] // "new" (OF) or "old" (EF) + if *caldir != "" { + config.SetCalendarsDir(*caldir) + } + if *sanctorale != "" { + caldata.SetSanctoraleDir(*sanctorale) + } + var useList []string + if *use != "" { + useList = strings.Split(*use, ",") + } + + form := args[0] // "new" (OF) or "old" (EF) lect := "new" tag := "of" if form == "old" { lect, tag = "traditional", "ef" } - y0, _ := strconv.Atoi(os.Args[2]) - y1, _ := strconv.Atoi(os.Args[3]) - outdir := os.Args[4] + y0, _ := strconv.Atoi(args[1]) + y1, _ := strconv.Atoi(args[2]) + outdir := args[3] base := func(sigla string) config.Config { c := config.Default() c.UILanguage = "en" c.Lectionary = lect c.SiglaStyle = sigla + c.Use = useList return c } cfgEN, cfgLA := base("english"), base("latin") |
