diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-18 13:59:26 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-18 13:59:26 +0200 |
| commit | 266b10d6cd2d44b4bccc36318054408ded80b8ce (patch) | |
| tree | fa7e5bdd618902fd1bcfc34318395a181f531254 /bin/main.ml | |
| parent | 150f8c550d2f9ebbac61d195eb342eb2b2ec6b95 (diff) | |
| parent | 36daf47dde9b0c16dacef31163ea74effdd5e7f3 (diff) | |
| download | colitur-266b10d6cd2d44b4bccc36318054408ded80b8ce.tar.gz colitur-266b10d6cd2d44b4bccc36318054408ded80b8ce.zip | |
merge: a flat INI overlay front end
A convenience format for simple local calendars, transpiled to the existing
S-expression form and verified against it before emitting.
Diffstat (limited to 'bin/main.ml')
| -rw-r--r-- | bin/main.ml | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/main.ml b/bin/main.ml index b997cbe..9b7c8a7 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -389,6 +389,7 @@ usage: colitur readings <year> the Mass reading citations, one line per day colitur day|readings <year> --overlay FILE [--overlay FILE ...] colitur new-overlay print a starter overlay file to stdout + colitur convert FILE.ini flat INI overlay -> S-expression, on stdout colitur check FILE ... load an overlay, say what it does, exit 2 if not colitur -h, --help this help colitur -V, --version print the version and exit @@ -432,6 +433,10 @@ overlays: Makefile or a pre-commit hook. It does not check a calendar against the rubrics -- nothing here can. + A flatter INI form exists for simple calendars, converted with + `colitur convert`, which verifies its own output before emitting + it. See colitur-overlay(5) for both forms. + In an added celebration, `citations` and `layer` may be omitted: they default to empty and to the overlay's own id. Dates may be (Fixed (month M) (day D)), (Easter_offset N) signed, or @@ -582,6 +587,36 @@ let check_report paths = paths; exit (if !ok then 0 else 2) +(* `colitur convert FILE.ini` -- the flat INI form to the S-expression one, + on stdout for redirection. + + A separate step rather than teaching --overlay to sniff the extension, and + deliberately so: the user gets to SEE what their INI became. When a date + form was mistyped or an edit silently dropped, "what did the engine + actually get" is the question, and an invisible transpile cannot answer it. + + {!Overlay_ini.convert} verifies its own output before returning it -- see + that function's own comment. Nothing is written if the round trip fails. *) +let convert_report path = + match + (try Ok (In_channel.with_open_text path In_channel.input_all) + with Sys_error e -> Error e) + with + | Error e -> + Printf.eprintf "colitur: %s\n" e; + exit 2 + | Ok text -> ( + match + Colitur_kernel.Overlay_ini.convert ~rank_of_string:Rite_ef.Vocab_ef.rank_of_string + ~rank_to_sexp:Rite_ef.Vocab_ef.sexp_of_rank ~rank_of_sexp:Rite_ef.Vocab_ef.rank_of_sexp text + with + | Error e -> + Printf.eprintf "colitur: %s: %s\n" path e; + exit 2 + | Ok sexp -> + print_string sexp; + exit 0) + (* `colitur new-overlay` -- a starter file on stdout, for redirection. Deliberately printed rather than written: the user picks the path, and a command that creates files where it likes is a worse citizen. Every value is @@ -660,6 +695,9 @@ let () = | "check" :: (_ :: _ as files) -> reject_overlays_for "check" overlays; check_report files + | [ "convert"; path ] -> + reject_overlays_for "convert" overlays; + convert_report path | [ "new-overlay" ] -> reject_overlays_for "new-overlay" overlays; print_string new_overlay_template; |
