From decb13fb17697f6d6d952c407f2173a714164804 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 19 Aug 2026 09:19:14 +0200 Subject: 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. --- test/cli.t | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'test') 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 + + + +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 -- cgit v1.3