Tarrapunchia / rust_grep

A simple grep clone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grust - A Grep in Rust

A simple grep clone implemented in rust.

Installation

Install Rustc/Cargo

Linux or Wsl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Other OS

Visit Rust Official Website

Enter project directory

cd /src

Compile the project in release mode

cargo build --release

The executable will be found in:

target/release

Usage/Examples

./grep_clone pattern path_to_file

if found

Pattern:        "pattern"
Path:           "path_to_file"
# "pattern" found at line [n]:
        "[...]pattern[...]"

For searching multiple patterns use '|' to separate them inside the same argument passed to the function, as in grep:

./grep_clone "pattern1\|pattern2\|..." path_to_file

The output it's slightly different, more grep-y, since the single pattern output could result confusing for multiple outputs:

Pattern:        "pattern"
Path:           "path_to_file"

        "[...]pattern1[...]pattern2[...]"

It automatically ensures if errors occur while executing and reports them in the stdout.

Roadmap

  • Make it work for one pattern ✅
  • Add colouring of the pattern searched inside the line printed ✅
  • Multiple patterns search ✅
  • Implementing grep flags ❌
  • Adding test cases ❌

About

A simple grep clone

License:GNU General Public License v3.0


Languages

Language:Rust 100.0%