diff options
| author | Lukasz Kasprzak <lukasz@arcofasiagroup.com> | 2026-08-27 14:12:43 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukasz@arcofasiagroup.com> | 2026-08-27 14:12:43 +0200 |
| commit | 34a36fcb0956db7f06c4b8860414283c03996293 (patch) | |
| tree | 09d642eb39545c1fe4a19a6f5afbe3785d6e653e /test | |
| parent | 4b3c18d61a243f1ec9c39e6279f7c687402b8dda (diff) | |
| download | colitur-34a36fcb0956db7f06c4b8860414283c03996293.tar.gz colitur-34a36fcb0956db7f06c4b8860414283c03996293.zip | |
feat(cli): --pretty, for reading in a terminal
The row commands print for awk: single-space fields, slugs, a variable tail.
That is right for the default and wrong for a person, who mostly wants to know
what today is.
--pretty gives the same four commands -- day, readings, rubrics, temporal --
aligned columns, the day's liturgical colour as a swatch, and commemorations
on their own indented line rather than lengthening the row. The colour was
already computed and simply thrown away on a terminal.
Colour is written only when stdout is a terminal, so piping or redirecting
yields plain aligned text: the alignment survives, the escapes do not, and the
swatch degrades to the colour's initial so the information is not lost with
them. NO_COLOR is honoured on PRESENCE whatever its value, which is the
convention's own rule -- treating it as a boolean is the usual way to get it
wrong.
Every other command refuses the flag rather than accepting it and doing
nothing: emit, table, render and publish already choose their shape through
--format and --template, and easter prints six key/value lines, not a grid.
An intermediate version accepted it everywhere and silently ignored it on
five commands, which is the failure mode this program refuses everywhere else.
Two things the layout had to learn. Column widths are a minimum, not a
maximum: the Latin season names run past them ("Tempus per annum ante
Septuagesimam" is 35 against 34), so pad always leaves a separator or the next
field fuses onto it -- that is how "Septuagesimam 1S. Hilarii" happened. And
the commemoration indent is measured from the row actually printed rather than
computed from the column constants, or it sits under the wrong column on
exactly the rows that have something to indent.
Presentation only: bin/pretty.ml decides nothing about what a day is, and
nothing reads it. Default output is byte-identical to v1.1.0 -- verified
across day, readings, rubrics, temporal and easter for 2026, 1583 and 9999.
Diffstat (limited to 'test')
| -rw-r--r-- | test/cli.t | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -1962,3 +1962,46 @@ the file is loaded once, unconditionally, before dispatch: $ XDG_CONFIG_HOME=xdg-bad colitur day 2027 --raw colitur: xdg-bad/colitur/config.ini: line 1: "[defaults" looks like a section header but does not end with ']' [2] + +`--pretty` lays the four row commands out for a person rather than for awk. +Opt-in: the default output above is untouched, byte for byte. Colour appears +only on a terminal, so this test -- which is a pipe -- sees the letter +fallback (w/r/g/v/o/k) rather than escape sequences: + + $ colitur day --pretty 2026 | head -1 + 2026-01-01 thu w I classis Tempus Nativitatis In Octava Nativitatis Domini + +A commemoration takes its own indented line rather than lengthening the row: + + $ colitur day --pretty 2026 | sed -n '/2026-01-14/,+1p' + 2026-01-14 wed w III classis Tempus per annum ante Septuagesimam 1 S. Hilarii Ep., Conf. et Eccl. Doct. + + S. Felicis Presbyt. et Mart. + +`readings --pretty` labels and stacks the citations, and prints the OF second +reading only on the days that have one: + + $ colitur readings --rite of --pretty 2026 | head -4 + 2026-01-01 thu of-mary-mother-of-god + First Num 6:22-27 + Second Gal 4:4-7 + Gospel Luc 2:16-21 + +NO_COLOR is honoured on presence, whatever its value -- that is the +convention's own rule, and reading it as a boolean is how tools get it wrong: + + $ NO_COLOR=0 colitur day --pretty 2026 | head -1 | cat -v | grep -c 'ESC' + 0 + [1] + +The commands that already choose their own shape refuse it, rather than +accepting it and quietly doing nothing: + + $ colitur emit --from 2026 --to 2026 --format csv --pretty + colitur: --pretty has no effect on `emit`; refusing rather than ignoring it + [2] + $ colitur table --year 2026 --template templates/ef/ordo.txt --pretty + colitur: --pretty has no effect on `table`; refusing rather than ignoring it + [2] + $ colitur easter 2026 --pretty + colitur: --pretty has no effect on `easter`; refusing rather than ignoring it + [2] |
