GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - copyleftdev/cora: Multi-pattern fixed-string matcher. Aho-Corasick + SIMD on mmap'd files. NDJSON output for AI agents and pipelines.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

cora

Tip my tokens

Multi-pattern fixed-string matcher. Searches files or stdin for one or more literal patterns using Aho-Corasick. Outputs NDJSON.

Requirements

  • Rust 1.70+ (uses edition 2021)

Install

cargo build --release
cp target/release/cora ~/.local/bin/

Usage

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.

Options

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

Output

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}}

Examples

# 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

Dependencies

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

License

MIT

About

Multi-pattern fixed-string matcher. Aho-Corasick + SIMD on mmap'd files. NDJSON output for AI agents and pipelines.

Topics

aho-corasickai-toolscligrepmmapndjsonpattern-matchingrustsimdtext-search

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.