| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Multi-pattern fixed-string matcher. Searches files or stdin for one or more literal patterns using Aho-Corasick. Outputs NDJSON.
cargo build --release
cp target/release/cora ~/.local/bin/cora [OPTIONS] <PATTERNS...> [-- FILES...]
Patterns can be labeled: err=ERROR produces matches tagged with the label err. Without a label, matches use the 0-based pattern index.
Reads from stdin when no files are given.
| Flag | Short | Description |
|---|---|---|
| --verbose | -v | Full-key NDJSON output |
| --insensitive | -i | Case-insensitive matching |
| --context N | -C N | Include N lines before/after each match |
| --max-matches N | -M N | Stop after N matches (0 = unlimited) |
| --count | -c | Summary only, no match lines |
| --pattern-file PATH | -f PATH | Read patterns from file (one per line, label=pattern, # comments) |
| --describe | Emit JSON capability manifest and exit |
Each match is one JSON line. Default mode uses short keys:
| Key | Type | Description |
|---|---|---|
| p | int | Pattern index (0-based) |
| n | string? | Pattern label (if provided) |
| l | int | Line number (1-based) |
| c | int | Column (1-based) |
| b | int | Byte offset from start of file/stream |
| m | string | Matched text |
| t | string | Full line text |
| f | string? | File path (omitted for stdin) |
| cb | string[]? | Context lines before (omitted when empty) |
| ca | string[]? | Context lines after (omitted when empty) |
Both modes are lossless — same fields, different key names. With -v, keys expand:
| Tune | Verbose |
|---|---|
| p | pattern_id |
| n | label |
| l | line |
| c | column |
| b | byte_offset |
| m | match |
| t | text |
| f | path |
| cb | context_before |
| ca | context_after |
The last line is always a summary:
{"_":"summary","n":42,"tr":false,"files":{"app.log":{"n":42,"sz":8192}},"pats":{"err":30,"warn":12}}# Search stdin
echo 'connection error detected' | cora error warning
# Search files with labeled patterns
cora 'err=ERROR' 'warn=WARN' -- app.log server.log
# Case-insensitive with context
cora -i -C 2 error -- app.log
# Count only
cora -c ERROR WARN -- *.log
# Patterns from file
cora -f patterns.txt -- app.log
# Machine-readable self-description
cora --describe| Crate | Purpose |
|---|---|
| aho-corasick | Multi-pattern matching |
| clap | CLI argument parsing |
| memmap2 | Memory-mapped file I/O |
| memchr | SIMD byte search |
| itoa | Integer formatting |
| serde / serde_json | Summary serialization |
| anyhow | Error handling |
MIT
| Back | FazBrowse Home | New Git URL |