| Crates.io | minigrep_wise |
| lib.rs | minigrep_wise |
| version | 0.1.0 |
| created_at | 2025-12-08 12:00:47.140817+00 |
| updated_at | 2025-12-08 12:00:47.140817+00 |
| description | This is an implementation of the minigrep project from the rust book project |
| homepage | |
| repository | https://github.com/wiseman-umanah/minigrep.git |
| max_upload_size | |
| id | 1973410 |
| size | 6,915 |
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.
cargo run <query> <path>
query – the text to search for.path – path to the file that should be scanned (for example poem.txt).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.
src/lib.rs, keeping src/main.rs very small.search and a search_case_insensitive function so logic can be unit-tested (cargo test).Run unit tests with:
cargo test
This covers both the case-sensitive and case-insensitive search helpers.