aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-19 09:19:14 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-19 09:19:14 +0200
commitdecb13fb17697f6d6d952c407f2173a714164804 (patch)
tree7c77e73aac02372df4e26b549029379f0b2a0756 /test
parent6abc243e5d40bd60174a3fb1affc9517b0ac5617 (diff)
downloadcolitur-decb13fb17697f6d6d952c407f2173a714164804.tar.gz
colitur-decb13fb17697f6d6d952c407f2173a714164804.zip
feat(cli): colitur emit -- csv, json, sexp, xml, ics
Reuses resolved_year_report's existing two-liturgical-year indexing rather than copying it: that walk owns the civil-vs-liturgical span reasoning, and a second copy would drift. It is refactored to return the days, with the printer layered on top, so day and readings behave identically -- which cli.t proves byte-for-byte. CSV emits one header for a whole multi-year run, not one per year. A reversed range is a usage error rather than silently empty output. Asserted in cli.t: two ics runs are byte-identical, because nothing in the path reads a clock.
Diffstat (limited to 'test')
-rw-r--r--test/cli.t69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/cli.t b/test/cli.t
index 1d4df3a..9b3373a 100644
--- a/test/cli.t
+++ b/test/cli.t
@@ -415,3 +415,72 @@ displaced silently.
$ colitur day 2026 --overlay ben.sexp | grep '^2026-03-21'
2026-03-21 saturday lent 4 transitus-of-our-holy-father-benedict class-1 white +ef-lent-4-saturday
+
+CSV emits a header and one row per day:
+
+ $ colitur emit --format csv --from 2027 --to 2027 | head -2
+ date,rite,season,week,slug,rank,colour,subject,name_la,name_en,first,gospel,comms
+ 2027-01-01,ef,christmastide,,ef-circumcision,class-1,white,temporal,,,Titus 2:11-15,Luke 2:21,
+
+ $ colitur emit --format csv --from 2027 --to 2027 | wc -l
+ 366
+
+JSON is one object, ICS one VCALENDAR:
+
+ $ colitur emit --format json --from 2027 --to 2027 | cut -c1-20
+ {"rite":"ef","year":
+
+ $ colitur emit --format ics --from 2027 --to 2027 | head -1 | cat -A | head -1
+ BEGIN:VCALENDAR^M$
+
+Two runs are byte-identical (no clock read anywhere):
+
+ $ colitur emit --format ics --from 2027 --to 2027 > /tmp/a.ics
+ $ colitur emit --format ics --from 2027 --to 2027 > /tmp/b.ics
+ $ cmp /tmp/a.ics /tmp/b.ics && echo identical
+ identical
+
+A multi-year range concatenates years in order, one header for the whole
+CSV run rather than one per year:
+
+ $ colitur emit --format csv --from 2027 --to 2028 | grep -c '^2028-'
+ 366
+
+ $ colitur emit --format csv --from 2027 --to 2028 | wc -l
+ 732
+
+sexp and xml are also available:
+
+ $ colitur emit --format sexp --from 2027 --to 2027 | wc -l
+ 8472
+
+ $ colitur emit --format xml --from 2027 --to 2027 | head -2
+ <?xml version="1.0" encoding="UTF-8"?>
+ <calendar rite="ef" year="2027">
+
+An unknown format is a usage error on stderr, exit 2:
+
+ $ colitur emit --format yaml --from 2027 --to 2027
+ colitur: unknown format "yaml" (want csv, json, sexp, xml or ics)
+ [2]
+
+emit refuses a reversed range rather than emitting nothing:
+
+ $ colitur emit --format csv --from 2028 --to 2027
+ colitur: --from 2028 is after --to 2027
+ [2]
+
+emit's own flags have no effect on the other commands, refused rather than
+silently ignored, the same discipline --overlay already gets:
+
+ $ colitur day 2027 --format csv
+ colitur: --format/--from/--to/--dtstamp have no effect on `day`; refusing rather than ignoring them
+ [2]
+
+day and readings are untouched:
+
+ $ colitur day 2027 | head -1
+ 2027-01-01 friday christmastide - ef-circumcision class-1 white
+
+ $ colitur readings 2027 | head -1
+ 2027-01-01 ef-circumcision | Titus 2:11-15 | Luke 2:21