miller/pkg/lib
John Kerl 40ac1b309e
Remove os.Exit callsites below the entrypoint: phase 1 (#2198)
* Rebuild docs: help-catalog index count drifted on main (666 -> 667)

Pre-existing drift from a recent catalog addition; surfaced by make dev.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Remove os.Exit callsites below the entrypoint: phase 1 (plans/exit.md)

Phase 1 of plans/exit.md: the mechanical swaps, plus the single-exit-point
scaffolding.

- New sentinel lib.ExitRequest{Code} (io.EOF-style control flow): returned by
  code paths that have already printed what they wanted (--version, -h,
  'put --explain' on a valid expression, 'put -x') instead of exiting mid-stack.
- pkg/entrypoint: new exitOnError() maps errors to exit codes in one place:
  ErrHelpRequested -> 0, ErrUsagePrinted -> 1, ExitRequest -> its code,
  anything else printed (JSON if --errors-json) -> 1.
- pkg/climain: version/help/usage/validation exits become returned errors;
  the ErrHelpRequested/ErrUsagePrinted -> exit translation moves up to the
  entrypoint; loadMlrrcOrDie becomes error-returning loadMlrrcFiles.
- Transformer ParseCLI/constructor exits -> returned errors (cut,
  having_fields, nest, reorder, merge_fields, reshape, rename, split, tee,
  subs, put_or_filter). merge_fields' bad-regex message formerly mis-reported
  itself as coming from the cut verb; tee's unrecognized-option exit was
  formerly silent; split/tee constructor failures formerly exited without
  printing the constructor's error.
- YAML/JSON record-writer marshal errors -> returned through Write, matching
  the CSV writer's error path.
- lib.WriteTempFileOrDie -> WriteTempFile (string, error); its sole caller
  (regtest diff helper) degrades gracefully.

Stderr messages and exit codes are byte-identical for all regression-covered
paths (4779 cases pass); runtime Transform-path exits are phase 3.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Add lib.NewExitZeroRequest() constructor for exit-0 sentinel returns

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 11:34:01 -04:00
..
doc.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
docurl.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
exit.go Remove os.Exit callsites below the entrypoint: phase 1 (#2198) 2026-07-15 11:34:01 -04:00
file_readers.go Convert if/else-if chains to typed switch statements (staticcheck QF1003) (#2112) 2026-06-28 18:27:42 -04:00
getoptify.go Add new tail -n +N, head -n -N options (#2071) 2026-06-21 10:34:16 -04:00
halfpipe.go Add mlr mcp MCP server + agent playbook, with a --no-shell gate (#2098 PR7) (#2133) 2026-07-03 19:41:49 -04:00
latin1.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
latin1_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
logger.go Strip dead code from pkg/ (#2121) 2026-07-01 19:32:13 -04:00
mlrmath.go Performance and style fixes (#1981) 2026-02-18 09:19:31 -05:00
ordered_map.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
paragraph.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
rand.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
readfiles.go Lint round 5+6: staticcheck and errcheck to zero (#2130) 2026-07-03 11:42:08 -04:00
README.md Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
regex.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
regex_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
shell_gate.go Add mlr mcp MCP server + agent playbook, with a --no-shell gate (#2098 PR7) (#2133) 2026-07-03 19:41:49 -04:00
stats.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
time.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
time_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
tsv_codec.go Convert if/else-if chains to typed switch statements (staticcheck QF1003) (#2112) 2026-06-28 18:27:42 -04:00
tsv_codec_test.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
unbackslash.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
unbackslash_test.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
util.go Remove os.Exit callsites below the entrypoint: phase 1 (#2198) 2026-07-15 11:34:01 -04:00

These are basic library routines for Miller.