Skip to content

Shen0000/wrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wrep

A simple and fast command-line tool to search for patterns in files, inspired by grep. Adapted from Command Line Applications in Rust

Description

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.

Installation

From Source

Clone the repository and build with Cargo:

git clone https://github.com/Shen0000/wrep
cd wrep
cargo build --release

The compiled binary will be available at target/release/wrep.

Using Cargo Install

cargo install wrep

Usage

wrep <PATTERN> <FILE>

Arguments

  • <PATTERN> - The text pattern to search for
  • <FILE> - The path to the file to search in

Examples

Search for the word "error" in a log file:

wrep error /var/log/app.log

Search for "TODO" in a source file:

wrep TODO src/main.rs

Output

wrep 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.

Error Handling

If the specified file doesn't exist or cannot be read, wrep will display an error message:

Error: could not read file `<filepath>`

Development

Running Tests

Run the unit tests:

cargo test

Run integration tests:

cargo test --test cli

Project Structure

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages