Skip to content

Let the engine return a status report and the CLI own the process to close #742 - #744

Merged
mathiasrw merged 1 commit into
mainfrom
fix/742
Oct 22, 2026
Merged

mathiasrw merged 1 commit into
mainfrom
fix/742

Conversation

@mathiasrw

Copy link
Copy Markdown
Owner

Closes #742

Change

  • The engine never touches the process. It resolves with a status report, or throws a panic when the run can not go on. Only src/cli.ts sets the exit code and ends the process.
  • The status report: files.searched, files.updated, pipe (bytes, type, updated), warnings and errors. It is collected as the run goes, also when the quiet flags hide the messages.
  • die() and --halt throw a panic in place of process.exit(). The engine adds the status so far, and the CLI exits with 1.
  • --status prints the status report as JSON with an indent of two spaces, after a line break. --status-compact (-S) prints it on one line.
  • With --verbose the status report also has engine: the version, the runtime, the config as it came in, what the regex engine was asked to do and the steps of the run.
  • --debug (-d) prints only the status report, with what went into the engine and what it did.
  • --quiet does not hide --verbose. --quiet-total hides it.
  • The debug output along the way (debug(), step()) is removed. The three lines that only --debug showed are now told by --verbose.
  • The CLI runs without an IIFE, and reads stdin with on('data').

Tests

  • rr() in test/js/helper.js still gives {out, err, exit}. rrStatus() gives the status report of the same run. A spy on process.exit fails the test if the engine ends the process.
  • test/js/fix/742.test.js tests the status report, the pipe types, panics, the engine part and the CLI flags.
  • test/js/debug.test.js tests the new --debug with the CLI.

@mathiasrw
mathiasrw merged commit 7c726df into main Oct 22, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/742 branch October 23, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let the engine return a status report and the CLI own the process

1 participant