Expand description
rgx filter subcommand — live/non-interactive regex filter over stdin or a file.
Re-exports§
Modules§
- app
- TUI-mode state for
rgx filter. - json_
path - Minimal dotted/indexed path language for JSONL field extraction.
- run
- TUI event loop for
rgx filter. - ui
- Rendering for
rgx filterTUI mode.
Structs§
Constants§
- EXIT_
ERROR - EXIT_
MATCH - Exit codes, matching grep conventions.
- EXIT_
NO_ MATCH - MAX_
LINE_ BYTES - Per-line byte cap. A single line above this size is truncated — prevents
one unterminated multi-gigabyte line from OOMing before
max_lineshelps. 10 MiB comfortably covers the largest real-world log lines (long stack traces, flattened JSON payloads) without letting a hostile stream run away.
Functions§
- emit_
count - Emit only the count of matched lines.
- emit_
matches - Emit matching lines to
writer. Ifline_numberis true, each line is prefixed with its 1-indexed line number and a colon. - entry
- CLI entry point for
rgx filter. Reads input, decides between non-interactive and TUI modes, and returns an exit code. - extract_
strings - Returns per-line extracted strings.
Nonemeans the line should be excluded from matching (JSON parse failure, path miss, or non-string value). The returned vector has the same length aslines, so callers can index it directly alongside the raw lines. - filter_
lines - Apply the pattern to each line. Returns the 0-indexed line numbers of every
line whose match status (matches vs. invert) satisfies
options.invert. - filter_
lines_ with_ extracted - Apply the pattern to the extracted string for each line. Lines whose
extracted[i]isNoneare excluded from the match set regardless of whether the pattern is empty orinvertis set — a missing/non-string field is not a “line” for matching purposes. - match_
haystack - Match one haystack against a compiled pattern and apply the
invertflag. ReturnsSome(spans)if the line should be emitted — an emptyVecin invert mode (since we don’t highlight “did-not-match” lines), or the actual match byte ranges otherwise. ReturnsNoneif the line should be filtered out. Centralizing this keepsfilter_lines,filter_lines_with_extracted, and the TUIcollect_matchespaths from drifting. - read_
input - Read all lines from either a file path or the provided reader (typically stdin).
Trailing
\n/\r\nis stripped per line. A trailing empty line (from a terminating newline) is dropped.