minigrep_wise 0.1.0

This is an implementation of the minigrep project from the rust book project
Documentation
  • Coverage
  • 66.67%
    6 out of 9 items documented3 out of 5 items with examples
  • Size
  • Source code size: 6.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 73.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wiseman-umanah/minigrep
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wiseman-umanah

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.