From 0506388da160a15ceddb0cea1a697d737103d5c4 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 11 Aug 2026 16:23:57 +0200 Subject: cli: emit "-" for an absent week, keeping output column-safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- bin/main.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bin/main.ml') 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 -- cgit v1.3