# 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
```bash
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:
```bash
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:
```bash
cargo test
```
This covers both the case-sensitive and case-insensitive search helpers.