simple_grep

Crates.iosimple_grep
lib.rssimple_grep
version0.1.0
created_at2025-06-11 12:23:09.501065+00
updated_at2025-06-11 12:23:09.501065+00
descriptionA simple command-line text search tool in Rust, inspired by grep
homepage
repositoryhttps://github.com/abdulaziz7225/simple-grep
max_upload_size
id1708523
size10,616
Abdulaziz Musaev (abdulaziz7225)

documentation

README

SimpleGrep ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ“„

A simple command-line text search tool in Rust, inspired by grep.
Supports both case-sensitive and case-insensitive search.


๐Ÿš€ Getting Started

Clone the repository and run with cargo:

cargo run -- <query> <input_file> > <output_file>

Example

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


๐Ÿ” Case Insensitive Search

To perform a case-insensitive search, set the environment variable IGNORE_CASE to 1:

IGNORE_CASE=1 cargo run -- Rust input.txt > output.txt

๐Ÿงช Running Tests

The app comes with a built-in test suite. Run all tests using:

cargo test

๐Ÿ›  Project Structure

  • 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.
Commit count: 6

cargo fmt