Skip to content
Proyectos

Acerca de

🍊 grep -o that already knows what a URL looks like. Pulls URLs, emails, IPs, hashes, JWTs, TODOs and more from any text.

Herramientas de desarrollo

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
Recopilando historial
in 15 days
Recopilando historial
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

squeeze CI Latest release License: MIT

squeeze pulls URLs, emails, UUIDs, IPs, TODOs, and 16 other kinds of data out of text. Pipe a log stream, point it at any file or directory, or embed it as a Rust library.

squeeze pulling timestamps, URLs, IPs, a UUID, an email, a version, a hash, and a handle out of a log file

Install

Homebrew (macOS and Linux):

brew install aymericbeaumet/tap/squeeze

mise (Linux, macOS, and Windows):

mise use -g github:aymericbeaumet/squeeze

Cargo (Rust 1.95+), from source:

cargo install --git https://github.com/aymericbeaumet/squeeze

All three install the squeeze command. Prebuilt binaries for Linux, macOS, and Windows on amd64 and arm64 are also on GitHub Releases, with SHA256SUMS for verifying downloads.

Usage

Pick one or more finders, or none to run all of them. With no path, squeeze reads stdin.

# URLs mentioned in commit messages, most recent first, with duplicates removed
git log --format=%B | squeeze --https --uniq

# IPs, IDs, and timestamps in logs, labeled by kind
kubectl logs deploy/api | squeeze --ip --uuid --datetime --with-kind

# TODOs and FIXMEs across a repository, with locations your editor understands
squeeze --todo --fixme --with-location .

# URLs as JSON, with their kind and position
squeeze --url --with-kind --output json notes.md

Directory scans respect ignore files. The usage guide covers input selection, output formats, and exit codes. For recipes such as ranking IPs in logs or opening a link from tmux scrollback, see integrations.

What it finds

Finder Flag Examples
CIDR --cidr 192.168.1.0/24, 2001:db8::/32
Codetags --codetag, --todo, --fixme TODO: fix this, FIXME(#42): bug
Colors --css-color #ff0000, rgb(255, 0, 0), hsl(0, 100%, 50%)
Datetimes --datetime 2024-01-15, 2024-01-15T10:30:00Z
Domains --domain example.com, mail.example.co.uk
Emails --email [email protected], [email protected]
Emojis --emoji 😀, 👨‍👩‍👧‍👦, 1️⃣
Env vars --env $HOME, ${PATH}, ${VAR:-default}
Handles --handle @alice, @[email protected]
Hashes --hash, --md5, --sha1, --sha256, --sha512 5d41402abc4b2a76b9719d911017c592
IPs --ip, --ipv4, --ipv6 192.168.1.1, ::1, 2001:db8::1
JSON --json {"key": "value"}, [1, 2, 3]
JWTs --jwt eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2ln
MACs --mac 00:1A:2B:3C:4D:5E, 001A.2B3C.4D5E
Modelines --modeline vim: set ts=4 sw=4 et:
Paths --path /etc/hosts, ./src/main.rs:42:10
Phones --phone +14155551234, (415) 555-1234
Semver --semver 1.0.0, v2.3.1-rc.1+build.42
URIs --uri, --url, --http, --https https://example.com, mailto:[email protected]
UUIDs --uuid 550e8400-e29b-41d4-a716-446655440000

Notes:

  • Finders favor precision over recall: they recognize common formats and may skip unusual valid values.
  • They extract candidates; they do not check whether a URL is reachable, an email address exists, or a JWT is authentic.
  • Matches can overlap (a URL can contain an IP); use --precedence longest to keep the longest overlapping match. Use grep or ripgrep for custom patterns.

Found something squeeze gets wrong? Report it with a sample input.

Performance

No regex engine is involved: SIMD searches and byte classification narrow the positions where a match can start, and large files, streams, and directory trees are scanned across every core. On a generated 56 MiB mixed corpus, single-threaded squeeze used 18 ms of CPU to extract URLs versus ripgrep's 35 ms. The tools use different URL grammars and return different match counts. See the benchmarks for the commands, data, and limitations.

Rust library

The finders are available as the squeeze-lib crate, imported as squeeze:

cargo add squeeze-lib
use squeeze::{email::Email, scanner::Scanner, uri::URI};

let scanner = Scanner::new(vec![Box::new(URI::default()), Box::new(Email::default())]);

let line = "Ping [email protected] about https://example.com/status";
for m in scanner.scan_line(line) {
    let kind = scanner.finders()[m.finder_index].id();
    println!("{kind}\t{}", &line[m.range]);
}

Configuring a finder returns a typed squeeze::Error, such as an unknown hash algorithm with a suggested fix; scanning never fails. See the API documentation for individual finders and scanner options.

Contributing

Bug reports, wrong matches, and pull requests are welcome. The contributing guide explains how to set up the project, where things live, and how to change a finder.

License

MIT

Explorar proyectos relacionados

Cargando…