| Crates.io | simple_grep |
| lib.rs | simple_grep |
| version | 0.1.0 |
| created_at | 2025-06-11 12:23:09.501065+00 |
| updated_at | 2025-06-11 12:23:09.501065+00 |
| description | A simple command-line text search tool in Rust, inspired by grep |
| homepage | |
| repository | https://github.com/abdulaziz7225/simple-grep |
| max_upload_size | |
| id | 1708523 |
| size | 10,616 |
A simple command-line text search tool in Rust, inspired by grep.
Supports both case-sensitive and case-insensitive search.
Clone the repository and run with cargo:
cargo run -- <query> <input_file> > <output_file>
cargo run -- Rust input.txt > output.txt
This will search for the word Rust in input.txt with case-sensitive matching and writes the result to output.txt file if there is no any error. Otherwise, it prints out the error message in standard error console
To perform a case-insensitive search, set the environment variable IGNORE_CASE to 1:
IGNORE_CASE=1 cargo run -- Rust input.txt > output.txt
The app comes with a built-in test suite. Run all tests using:
cargo test
main.rs: Entry point that parses CLI arguments and calls the search logic.lib.rs: Contains the Config struct and the run, search, and search_case_insensitive functions.tests/lib_test.rs: Unit tests for both case-sensitive and case-insensitive search.