grepr

Crates.iogrepr
lib.rsgrepr
version0.1.1
sourcesrc
created_at2023-07-21 01:48:14.493268
updated_at2023-07-21 01:48:14.493268
descriptionA minimal implementation of grep in Rust.
homepage
repositoryhttps://github.com/jonduesterhoeft/grepr
max_upload_size
id921974
size44,869
Jon Duesterhoeft (jonduesterhoeft)

documentation

README

grepr

Rust

A minimal version of grep implemented in Rust.

Overview

grepr is a simple command line search tool. A search string and file path are input as arguments, along with several optionals to fine tune the search. The program iterates through each line in the specified file and will return any lines matching the search criteria.

Options

Optional arguments are shown via the --help flag.

$ grepr --help
A simple to use command line search tool, à la grep.

Usage: mgrep [OPTIONS] <QUERY> <PATH>

Arguments:
  <QUERY>  Search query
  <PATH>   File path

Options:
  -i, --ignore-case   Ignores case whiles searching
  -v, --invert-match  Inverst search results
  -w, --word          Matches exact words only
  -l, --line          Matches exact lines only
  -h, --help          Print help
  -V, --version       Print version

Examples

A simple search example.

$ grepr sunbeam tests/pale_blue_dot.txt

test/pale_blue_dot.txt
11: on a mote of dust suspended in a sunbeam.

Search for an exact word. In this case any non-alphanumeric characters are ignored.

$ grepr "in" tests/pale_blue_dot.txt -w

test/pale_blue_dot.txt
6: civilization, every king and peasant, every young couple in love, 
9: "superstar," every "supreme leader," every saint and sinner in 
11: on a mote of dust suspended in a sunbeam.

Inverting the search results. All lines without a match are returned.

$ grepr a tests/pale_blue_dot.txt -v

test/pale_blue_dot.txt
1: On it everyone you love, everyone you know, everyone you ever 
10: the history of our species lived there--
12: 

Commit count: 68

cargo fmt