diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
| commit | c9f3bf46f0de09edb796e35f3dcff349febf75c9 (patch) | |
| tree | c1a0b98b484e4da557c1ab205dfff0d92ce8ac36 /internal/readings/readings.go | |
| parent | a865374755480a4aef2a6156afccdf08a91422ea (diff) | |
| download | lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.tar.gz lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.zip | |
dayinfo: show feast/day name + colour (modern niedziela + traditional missalemeum) in cli/tui/web; v0.5.0
Diffstat (limited to 'internal/readings/readings.go')
| -rw-r--r-- | internal/readings/readings.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/internal/readings/readings.go b/internal/readings/readings.go index ac7209a..047e901 100644 --- a/internal/readings/readings.go +++ b/internal/readings/readings.go @@ -28,29 +28,33 @@ type Options struct { All bool } -// Load fetches the day's sections for the configured lectionary -// (cfg.Lectionary: "traditional" or "new") and applies part filtering. -// Returns liturgy.Section values regardless of source. -func Load(cfg config.Config, opts Options) ([]liturgy.Section, error) { +// Load fetches the day's sections and its DayInfo (celebration name, +// temporal, liturgical colour -- see liturgy.DayInfo) for the configured +// lectionary (cfg.Lectionary: "traditional" or "new") and applies part +// filtering. Returns liturgy.Section values regardless of source. A source +// that yields no DayInfo (see liturgy.Load/tradlit.Load) comes back as a +// zero liturgy.DayInfo, not an error -- callers omit the header for it. +func Load(cfg config.Config, opts Options) ([]liturgy.Section, liturgy.DayInfo, error) { offline := opts.Offline || cfg.Offline var secs []liturgy.Section + var info liturgy.DayInfo var err error if cfg.Lectionary == "traditional" { - secs, err = tradlit.Load(opts.Date, cfg.TraditionalLang, offline) + secs, info, err = tradlit.Load(opts.Date, cfg.TraditionalLang, offline) } else { - secs, err = liturgy.Load(liturgy.Options{ + secs, info, err = liturgy.Load(liturgy.Options{ Date: opts.Date, Refresh: opts.Refresh, Offline: offline, }) } if err != nil { - return nil, err + return nil, liturgy.DayInfo{}, err } - return filterParts(secs, cfg, opts.All), nil + return filterParts(secs, cfg, opts.All), info, nil } // filterParts keeps only the gospel when !all (PartID "ewangelia" modern or |
