reverse cli command

This commit is contained in:
Gregor Lohaus
2026-05-22 09:09:56 +02:00
parent bda6e8cc40
commit 28a2a771e8
7 changed files with 321 additions and 3 deletions

View File

@@ -170,6 +170,29 @@ The map contains a flat lookup from rendered strings to template tokens plus per
}
```
## Reverse CLI
Use the reverse map to rebuild template files from an edited rendered directory:
```sh
tdir reverse ./output ./templates
```
Without installing the package first, run the published CLI through Bun:
```sh
bunx @gregorlohaus/tdir reverse ./output ./templates
```
By default, the command reads `./output/.tdir-map.json`. Use `--map` for a custom map path relative to the rendered directory:
```sh
tdir reverse ./output ./templates --map meta/reverse-map.json
bunx @gregorlohaus/tdir reverse ./output ./templates --map meta/reverse-map.json
```
The command writes files at their original template paths and restores recorded `<@var(...)>` tokens in file contents and file paths. It does not infer conditional blocks that were removed during rendering; keep the original template structure when those blocks need to be preserved.
## Unmatched directives
A `<@if>` without a matching `<@endif>` throws when the renderer is initialized: