aboutsummaryrefslogtreecommitdiff
path: root/internal/cli/cli.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 13:23:51 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-27 13:23:51 +0200
commite91a7dadb4401a553ffdd4f3661640921e425eb6 (patch)
tree94df3ed52204c186c505a19e1efc650895edf795 /internal/cli/cli.go
parentfb3fdc69fad0f374c419559d99d75ba8c81aa632 (diff)
downloadlectio-e91a7dadb4401a553ffdd4f3661640921e425eb6.tar.gz
lectio-e91a7dadb4401a553ffdd4f3661640921e425eb6.zip
feat(cli): --cal-new scaffold + --cal-check lint for custom calendar layers
Also: reject out-of-range MM-DD in resolveDate (strict validation for user data).
Diffstat (limited to 'internal/cli/cli.go')
-rw-r--r--internal/cli/cli.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go
index 51a5a4b..575fba9 100644
--- a/internal/cli/cli.go
+++ b/internal/cli/cli.go
@@ -49,6 +49,8 @@ Flags:
--citation print the day's gospel reference (scripts/cron) and exit
--week list the coming week's gospel references and exit
-L, --liturgy print the computed liturgical day (offline, no network) and exit
+ --cal-new NAME scaffold a custom calendar layer ~/.config/lectio/calendars/NAME.ini
+ --cal-check NAME validate a custom calendar layer NAME.ini and exit
--rand, --rand-v print a random verse and exit (uses default_version or -b VER;
bt has no corpus, so it falls back to a corpus version)
--rand-ch print a random chapter and exit
@@ -121,6 +123,7 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
var list bool
var ref string
var liturgy bool
+ var calNew, calCheck string
fs := flag.NewFlagSet("lectio", flag.ContinueOnError)
fs.SetOutput(stderr)
@@ -167,6 +170,8 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
fs.StringVar(&calendar, "calendar", "", "export a month (YYYY-MM) as a printable A4 PDF calendar")
fs.BoolVar(&liturgy, "L", false, "print the computed liturgical day (offline calendar engine) and exit")
fs.BoolVar(&liturgy, "liturgy", false, "print the computed liturgical day (offline calendar engine) and exit")
+ fs.StringVar(&calNew, "cal-new", "", "scaffold a new calendar-layer file NAME.ini and exit")
+ fs.StringVar(&calCheck, "cal-check", "", "validate the calendar-layer file NAME.ini and exit")
if err := fs.Parse(rest); err != nil {
return 2
@@ -192,6 +197,12 @@ func Run(args []string, stdin io.Reader, stdout, stderr io.Writer) int {
if update {
return runHarvest(date, stdout, stderr)
}
+ if calNew != "" {
+ return runCalNew(calNew, stdout, stderr)
+ }
+ if calCheck != "" {
+ return runCalCheck(calCheck, stdout, stderr)
+ }
cfg, err := config.Load()
if err != nil {