aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 16:23:57 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-11 16:23:57 +0200
commit0506388da160a15ceddb0cea1a697d737103d5c4 (patch)
tree1a186d3f6a8a8d10b027cde6c49d4d11cf7735d4 /bin
parent23892f0a5933851e90fb8b6aef5c3b6f7e24bc1b (diff)
downloadcolitur-0506388da160a15ceddb0cea1a697d737103d5c4.tar.gz
colitur-0506388da160a15ceddb0cea1a697d737103d5c4.zip
cli: emit "-" for an absent week, keeping output column-safe
week is "" for roughly 30 days a year (any day outside a numbered week). Printed as-is among seven space-separated fields, that collapses two fields into a double space, so naive field-position parsing (e.g. awk '{print $4}') silently reads the wrong column on those days -- a real defect for a project whose stated design is Unix-composable CLIs. Emit "-" instead, so every line always has exactly seven single-space-separated fields. Record.headers/to_row exist for exactly this kind of column-safe encoding but use a different column set and order than this CLI's documented date/weekday/season/week/slug/rank/colour format (design spec ยง6); adopting them here would be a larger, unrequested format change, so this keeps the CLI's own field list and only substitutes the empty value. The cram test's pinned lines are re-verified against liturgical anchors before promoting, not blind-promoted: 1 Jan 2026 (Circumcision, class-1, white) and 2-3 Jan (ordinary class-4 Christmastide ferias, the finding-1 slug fix already re-pinned separately) are correct; 2026-04-05 remains the sole Easter Sunday line, Paschaltide week 1, class-1, white, matching the independently-computed Easter anchors printed by `colitur easter 2026` immediately above in the same file.
Diffstat (limited to 'bin')
-rw-r--r--bin/main.ml8
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/main.ml b/bin/main.ml
index 827e6f2..896a6bd 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -21,6 +21,12 @@ let temporal_report y =
| Ok t -> t
| Error e -> failwith e
in
+ (* [week] is "" for roughly 30 days a year (outside any numbered week);
+ printed as-is, that collapses two of the seven space-separated fields
+ into a double space, so naive field-position parsing (e.g. awk '{print
+ $4}') silently reads the wrong column on those days. Emit "-" instead,
+ so every line always has exactly seven single-space-separated fields. *)
+ let field s = if s = "" then "-" else s in
let d = ref jan1 in
while D.compare !d dec31 <= 0 do
let t = Rite_ef.Temporal_ef.temporal !d in
@@ -30,7 +36,7 @@ let temporal_report y =
in
Printf.printf "%s %s %s %s %s %s %s\n" r.Colitur_kernel.Record.date
r.Colitur_kernel.Record.weekday r.Colitur_kernel.Record.season
- r.Colitur_kernel.Record.week r.Colitur_kernel.Record.slug
+ (field r.Colitur_kernel.Record.week) r.Colitur_kernel.Record.slug
r.Colitur_kernel.Record.rank r.Colitur_kernel.Record.colour;
d := D.add_days !d 1
done