From cc6655134e155dd0879ecb8eb009271e17488834 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 17 Aug 2026 16:19:02 +0200 Subject: feat(cli): --version, a CHANGELOG, and a release target Groundwork for tagging. The project had no version anywhere: not in dune-project, not in the binary, no CHANGELOG, no tags. The version lives in two places -- dune-project, which generates colitur.opam, and a constant in bin/main.ml, which is what --version prints. Two rather than one because dune's watermarking only substitutes in a release tarball, so a binary built the ordinary way from a checkout would report a placeholder. The release target rewrites both and then re-checks both, and finally requires the freshly built binary to report the version it just wrote: a release that bumped one and not the other would ship a binary disagreeing with its own package metadata. --version is deliberately not embedded in the help text. cli.t pins help's first line, and a version there would mean editing a test expectation every release for no gain. The release target mirrors lectio's, refusals included: no release from a dirty tree, none without a CHANGELOG entry for that version, none whose version bump silently failed to apply, and `make check` -- the full 1583-9999 sweep, not the sampling suite -- must pass before the tag is created. --- bin/main.ml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin/main.ml') diff --git a/bin/main.ml b/bin/main.ml index 573f190..141f016 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -336,6 +336,17 @@ let readings_report y = resolved_year_report ~line:readings_line y pager or grepped); being invoked wrongly is an error, so [usage] prints a one-liner to stderr and exits 2, keeping stdout clean for whatever the caller was really trying to capture. *) +(* Kept in lockstep with dune-project's own [(version ...)] by `make release`, + which bumps BOTH and refuses to proceed if either edit did not take. Two + places rather than one because dune's watermarking (`dune subst`) only + substitutes in a release tarball, not in a plain `dune build` from a + checkout, so a binary built the ordinary way would report a placeholder. + A constant edited by the release target is what lectio does too, for the + same reason. Deliberately NOT embedded in [help_text]: the cram test pins + help's first line, and a version in it would make every release edit a + test expectation for no gain. *) +let version = "0.1.0" + let help_text = {|colitur -- deterministic liturgical calendar engine (Roman rite, 1962) @@ -345,6 +356,7 @@ usage: colitur day the resolved day identity, one line per day colitur readings the Mass reading citations, one line per day colitur -h, --help this help + colitur -V, --version print the version and exit is a civil year, 1583..9999 inclusive. Each report covers 1 January to 31 December of that year, not a liturgical year. @@ -394,6 +406,9 @@ let with_year ys f = let () = match Sys.argv with | [| _; ("-h" | "--help" | "help") |] -> print_help () + | [| _; ("-V" | "--version" | "version") |] -> + print_endline version; + exit 0 | [| _; "easter"; ys |] -> with_year ys easter_report | [| _; "temporal"; ys |] -> with_year ys temporal_report | [| _; "day"; ys |] -> with_year ys day_report -- cgit v1.3