minigrep_wise

Crates.iominigrep_wise
lib.rsminigrep_wise
version0.1.0
created_at2025-12-08 12:00:47.140817+00
updated_at2025-12-08 12:00:47.140817+00
descriptionThis is an implementation of the minigrep project from the rust book project
homepage
repositoryhttps://github.com/wiseman-umanah/minigrep.git
max_upload_size
id1973410
size6,915
Wiseman Umanah (wiseman-umanah)

documentation

README

minigrep

A small command-line clone of grep written while working through the Rust book. It loads a file, looks for a query string, and prints every matching line. The exercise focuses on learning how to structure a medium-sized Rust binary crate, handle errors, and write unit tests.

Usage

cargo run <query> <path>
  • query – the text to search for.
  • path – path to the file that should be scanned (for example poem.txt).
  • By default the search is case-sensitive. Set CASE_INSENSITIVE=1 to switch to case-insensitive search.

Examples:

cargo run to poem.txt
CASE_INSENSITIVE=1 cargo run rUsT poem.txt

Both commands return the lines containing the query. When the query is missing or the file cannot be read, the program exits with a non-zero status and prints a helpful message.

Development notes

  • Argument parsing and configuration live in src/lib.rs, keeping src/main.rs very small.
  • The library exposes a search and a search_case_insensitive function so logic can be unit-tested (cargo test).
  • The project sticks to the Rust standard library; no external crates are required.

Testing

Run unit tests with:

cargo test

This covers both the case-sensitive and case-insensitive search helpers.

Commit count: 0

cargo fmt