Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
918855d
Give a panic and not a stack trace when a path can not be looked at
mathiasrw Oct 23, 2026
e366dd6
Stop starting new files after a panic with --halt
mathiasrw Oct 23, 2026
ff4c0e5
Read the piped paths of --glob-pipe as UTF-8
mathiasrw Oct 23, 2026
9b6aec0
Remove control characters from the new names of --rename
mathiasrw Oct 23, 2026
a2c62df
Give a message and not a crash when --js code throws something that i…
mathiasrw Oct 23, 2026
8be509b
Name a thrown error whose message can not be read, and cut a big thro…
mathiasrw Oct 23, 2026
eab2c2b
Tell where --js code failed in a module with --verbose
mathiasrw Oct 23, 2026
e225977
Read each line of the stack, skip what is not the code of the user, a…
mathiasrw Oct 23, 2026
2ad9cd2
Only make the --js numbers the code uses, and only count files for $i…
mathiasrw Oct 23, 2026
71b1a51
Tell in the help that only the numbers the code names are made
mathiasrw Oct 23, 2026
1b890fe
Leave the README line of --js to #838, so the stack can be rebased wi…
mathiasrw Oct 23, 2026
07dbd4d
Let --js code declare the names of the numbers and groups with let an…
mathiasrw Oct 23, 2026
f7b634f
Use the prefix rr_ for named groups in --js, and panic on a name that…
mathiasrw Oct 23, 2026
c3fcc36
Do not panic on a group name that ends with _ under --output-match
mathiasrw Oct 23, 2026
9e52141
Find named groups with letters that are not ASCII in --js
mathiasrw Oct 23, 2026
6cb7e62
Read the named groups from the regex, and see rr_year_ on its own
mathiasrw Oct 23, 2026
f736bf4
Use the path of --replacement-file as it is, with no escapes and no a…
mathiasrw Oct 23, 2026
d74c213
Tell why a replacement file can not be read, and only once
mathiasrw Oct 23, 2026
02e974e
Show the reason in words, and the path as it is unless it hides a char
mathiasrw Oct 23, 2026
24879e8
Sort a file that is gone before the sort last, and do not crash
mathiasrw Oct 23, 2026
870b691
Only sort a deleted file last, and give other stat errors their reason
mathiasrw Oct 23, 2026
16161a4
Make the natural order the same on Node and Bun, and in every locale
mathiasrw Oct 23, 2026
9c69a0d
Run the test of the natural order with --sort
mathiasrw Oct 23, 2026
29146e2
Make the README and the help true about --quiet, --debug, --simulate,…
mathiasrw Oct 23, 2026
c200a42
Make the README and help true about --quiet, --debug and the escapes
mathiasrw Oct 23, 2026
d618a25
Tell in the README that only the --js numbers the code names are made
mathiasrw Oct 23, 2026
2533c6c
End the run as usual when the reader of a pipe stops early
mathiasrw Oct 23, 2026
c9079a4
Take in the newest commits of the PRs below, so the cleanup is made o…
mathiasrw Oct 23, 2026
09cb129
Simplify the engine, split the status from the output, and name funct…
mathiasrw Oct 23, 2026
e666df9
Merge main into cleanup/engine, on top of the numbers of #830 and the…
mathiasrw Oct 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions devguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ How we like the code in RexReplace to be.

## Telling what is going on

All output goes through `src/output.ts`. Pick the function by who the message is for:
All output goes through `src/output.ts`, which only prints. What a run records in its status, and the panic, are in `src/status.ts`, which prints through `output.ts`. Pick the function by who the message is for:

| Function | Shown when | For | Example |
| --- | --- | --- | --- |
| `print(item, delimiter, tail, stream)` | Always | The result. Puts the delimiter after each item, or only between them without a tail. Without a delimiter it is a line break, unless the item already ends with one. | A name, the content of a file, a match |
| `printDone()` | At the end of a run, also when it is stopped | Ends stdout and stderr with a line break when `--nl` is set | |
| `info(name)` | Unless `--quiet` | The name of an affected file. stdout, or stderr when stdout has content. | `a.md` |
| `printName(name)` | Unless `--quiet` | The name of an affected file. stdout, or stderr when stdout has content. | `a.md` |
| `warn(msg)` | Unless `--quiet` | Something is likely a mistake, or there is nothing to do, but the run goes on. Starts with 🟡. Also added to `status.warnings`. | `0 files found` |
| `error(msg, data)` | Unless `--quiet-total` | Something went wrong. Starts with ❌, and the data, like the file, is on its own line under the message. The run goes on, unless `--halt` is set: then a panic is thrown. Also added to `status.errors`, so the CLI gives the exit code 2. | `File not found`, and `a.md` on the next line |
| `checkFailed(text)` | Unless `--quiet-total` | A check from `--expect-*` that is not met. An error, also in `status.checks`, so the CLI gives the exit code 1 when the failed checks are the only errors. | `Expected a diff, but nothing was changed` |
| `panic(msg, data, help)` | Unless `--quiet-total` | Something went wrong and the run can not go on. Starts with ❌, ends with `No further processing.`, and throws a panic, so the CLI exits with 3. Also added to `status.errors`. | `No data piped into replacement` |
| `chat(msg)` | `--verbose`, also with `--quiet`, but not with `--quiet-total` | The user: what happens to each file. Only ever to stderr. Also kept in `engine.steps` of the status report. | `Open sync: a.md`, `Nothing changed in: a.md` |
| `checkFailed(text)` (inside `checkExpectations()`) | Unless `--quiet-total` | A check from `--expect-*` that is not met. An error, also in `status.checks`, so the CLI gives the exit code 1 when the failed checks are the only errors. | `Expected a diff, but nothing was changed` |
| `panic(msg, data)` | Unless `--quiet-total` | Something went wrong and the run can not go on. Starts with ❌, ends with `No further processing.`, and throws a panic, so the CLI exits with 3. Also added to `status.errors`. | `No data piped into replacement` |
| `verbose(msg)` | `--verbose`, also with `--quiet`, but not with `--quiet-total` | The user: what happens to each file. Only ever to stderr. Also kept in `engine.steps` of the status report. | `Open sync: a.md`, `Nothing changed in: a.md` |

- What the run did is in the status report: the engine resolves with it, and `--status` prints it. So there is no extra debug output to print along the way.
- `--debug` prints the status report, with what went into the engine and what it did, and hides the rest, except the content of `--output` and the matches of `--output-match`.
Expand Down
7 changes: 3 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// CLI interface for rexreplace

import * as rexreplace from './engine.ts';
import {outputConfig, panic, writeTo} from './output.ts';
import {writeTo} from './output.ts';
import {statusConfig, panic} from './status.ts';
import {alias} from './alias.ts';

// Make it visible when Bun is the runtime (like with rexreplace-bun) as the regex engine is then not the one from Node.
Expand Down Expand Up @@ -592,12 +593,10 @@ if (config.debug) {
config.status = config.verbose = config.quietTotal = true;
}

outputConfig(config);
statusConfig(config);

config.pipedData = null;

config.showHelp = yargs.showHelp;

config.pattern = pattern;

config.includeGlob = yargs.argv._;
Expand Down
Loading
Loading