A simple and fast command-line tool to search for patterns in files, inspired by grep. Adapted from Command Line Applications in Rust
wrep is a lightweight file search utility written in Rust that allows you to search for text patterns within files. It reads a file and displays all lines that contain the specified pattern.
Clone the repository and build with Cargo:
git clone https://github.com/Shen0000/wrep
cd wrep
cargo build --releaseThe compiled binary will be available at target/release/wrep.
cargo install wrepwrep <PATTERN> <FILE><PATTERN>- The text pattern to search for<FILE>- The path to the file to search in
Search for the word "error" in a log file:
wrep error /var/log/app.logSearch for "TODO" in a source file:
wrep TODO src/main.rswrep outputs all lines from the file that contain the search pattern. Each matching line is printed to stdout exactly as it appears in the file.
If the specified file doesn't exist or cannot be read, wrep will display an error message:
Error: could not read file `<filepath>`
Run the unit tests:
cargo testRun integration tests:
cargo test --test clisrc/main.rs- Command-line interface and argument parsingsrc/lib.rs- Core pattern matching logictests/cli.rs- Integration tests
MIT