cloverleaf-larry/bin/cl-format-migrate
Bryan Johnson 9233d23cda v0.9.12: cl-format-migrate (table/xlate CRLF→LF + native-convert) + cdr/cds/cdd + bare-site shortcuts
New `larry tools cl-format-migrate <dir>`: fixes the "' before prologue start" errors on
Windows-authored tables/xlates whose CRLF line endings choke the Linux Cloverleaf parser
(and Cloverleaf's own hcitblconvert/hcixltconvert). Root cause field-confirmed by Bryan:
`file` shows broken=CRLF/working=LF, both version:6.0 (no format bump) — the stray CR is
read as a bogus char before the prologue keyword.

- Default: strip ONLY trailing CR (sed 's/\r$//'), backup-first via journal.sh, idempotent
  (SKIP already-LF), per-file verify (no trailing CRLF remains + prologue block intact),
  summary report. Bryan proved a CR-stripped table loads clean.
- Opt-in --run-native-convert: chains hcitblconvert/hcixltconvert after a successful strip
  (Cloverleaf's real format bump), resolving the bare name against <site>/Tables|Xlate then
  $HCIROOT/Tables|Xlate, one name per call; separate journal checkpoint so a native-step
  failure auto-rolls-back to the CR-stripped-safe state. Orphan file -> NATIVE_SKIPPED (never
  guesses a site). Default stays strip-only pending Bryan's hcitblconvert-post-strip confirm.
- Unified tbl+xlt (both choke on CRLF identically).
- QoL REPL: cdr->$HCIROOT, cds->$HCIROOT/$HCISITE, cdd->$HCIROOT/$HCISITE/data; bare site name
  -> setsite+cd, first-match-wins ordering so it never shadows an existing command.

Vera CODE-PASS (re-gate after fixing a Major verify defect: _count_cr matched any CR byte ->
false FAILED_VERIFY loop on files with a legitimate mid-line CR; now _count_trailing_cr on
\r$, matching the strip). Own-fixture verified: convert/preserve-mid-line-CR/converge-to-SKIP,
full regression + --run-native-convert mocked suite, bash -n 3.2.57, manifest --check clean.
Live-acceptance: Bryan (Gundersen box; dry-run -> single-file --confirm pilot -> batch).
2026-07-23 13:22:58 -07:00

14 lines
758 B
Bash
Executable File

#!/usr/bin/env bash
# cl-format-migrate — direct, on-PATH wrapper for lib/cl-format-migrate.sh
# (no `larry tools` prefix needed). All args pass straight through;
# -h/--help is handled by the underlying tool.
#
# cl-format-migrate /opt/cloverleaf/cis2025.01/integrator/adt/tables --dry-run
# cl-format-migrate . --type tbl --confirm yes --out /tmp/cl-format-report
set -o pipefail
_self="${BASH_SOURCE[0]}"; [ -L "$_self" ] && _self="$(readlink "$_self")"
. "$(cd "$(dirname "$_self")" && pwd)/_nc_common.sh"
lib="$(_nc_resolve_lib)" || { echo "cl-format-migrate: lib/ toolkit not found (set LARRY_LIB_DIR or LARRY_HOME)" >&2; exit 1; }
if [ $# -eq 0 ]; then exec bash "$lib/cl-format-migrate.sh" --help; fi
exec bash "$lib/cl-format-migrate.sh" "$@"