simple_grep 0.1.0

A simple command-line text search tool in Rust, inspired by grep
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented4 out of 5 items with examples
  • Size
  • Source code size: 10.61 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 319.63 kB This is the summed size of all files generated by rustdoc for all configured targets
  • ร˜ build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • abdulaziz7225/simple-grep
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • abdulaziz7225

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.