feat: add persistent scan_index/url_policy state with --rescan and --reset-url-policy
This commit is contained in:
@@ -39,24 +39,31 @@ mdlink .
|
||||
- `--timeout FLOAT`
|
||||
Per-request timeout in seconds (default: `10.0`).
|
||||
- `--rescan`
|
||||
Discard `.mdlink-state.json` and run a full scan on all matching files.
|
||||
Reset only `scan_index` in `.mdlink-state.json` and run a full scan on all matching files.
|
||||
- `--reset-url-policy`
|
||||
Clear all stored URL ignore policies before scanning.
|
||||
- `--check CODE`
|
||||
Report only selected HTTP status codes. Repeat option for multiple codes (for example `--check 404` or `--check 301 --check 404`).
|
||||
|
||||
By default, `mdlink` stores scanned file paths in `.mdlink-state.json` and skips those files in later runs.
|
||||
By default, `mdlink` stores:
|
||||
|
||||
- `scan_index`: already scanned files for incremental directory scans.
|
||||
- `url_policy`: ignored URL decisions per file.
|
||||
|
||||
Single-file scans do not use state.
|
||||
|
||||
## Interactive Redirect Rewrite
|
||||
|
||||
Step 1: When a Markdown link redirects, `mdlink` prompts:
|
||||
|
||||
```text
|
||||
Replace old URL with final URL? [y/N]
|
||||
Replace old URL? [y/N]
|
||||
```
|
||||
|
||||
Step 2: For `http://` Markdown links without redirect, `mdlink` can test an `https://` variant and prompt:
|
||||
|
||||
```text
|
||||
Replace HTTP URL with HTTPS variant? [y/N]
|
||||
Replace old URL? [y/N]
|
||||
```
|
||||
|
||||
Only confirmed links are updated.
|
||||
@@ -65,25 +72,25 @@ Only confirmed links are updated.
|
||||
|
||||
This repository includes:
|
||||
|
||||
- `test.sh`: Generates a sample Markdown test file.
|
||||
- `test.md`: A sample file with mixed link cases (200, redirect, 404/500, naked URLs, ignored image/non-http links).
|
||||
- `test.sh`: Generates three sample Markdown files in `testdata/` and runs state-related checks.
|
||||
- `testdata/*.markdown`: Sample files with mixed link cases (200, redirect, 404/500, naked URLs, ignored image/non-http links).
|
||||
|
||||
Generate or overwrite `test.md`:
|
||||
Generate test data and run checks:
|
||||
|
||||
```bash
|
||||
./test.sh
|
||||
```
|
||||
|
||||
Generate to a custom file path:
|
||||
Generate test data only:
|
||||
|
||||
```bash
|
||||
./test.sh /tmp/my-test.md
|
||||
./test.sh --generate-only
|
||||
```
|
||||
|
||||
Run the tool against the generated test file:
|
||||
Run the tool against generated test data:
|
||||
|
||||
```bash
|
||||
mdlink test.md
|
||||
mdlink testdata
|
||||
```
|
||||
|
||||
## Help
|
||||
|
||||
Reference in New Issue
Block a user