gurbaaz27 / minigrep-rust

Rust implementation of the basic form of grep. Used CLAP for better argument parsing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minigrep implementation in Rust

Far inferior to grep command, but still it returns lines from a file containing your query string, both case strictly and flexibly by passing a flag in argument.

Requirements

Clap dependency has been added in the Cargo.toml file already. It provides neat Command Line Argument Parsing, which is essentially its full-form. 😊

Usage

git clone link-to-repo
cd minigrep_rust
cargo run -- --help
My Own Rust CLI MiniGrep! 
Gurbaaz Singh Nandra <gurbaaz27.github.io>
Returns the lines in file containing your query.

USAGE:
    minigrep_rust --case_sensitive <case_sensitive> --filename <filename> --query <query>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -c, --case_sensitive <case_sensitive>    Whether the search be case-insensitive(n) or sensitive(y). [default: y]
    -f, --filename <filename>                String of filename(with extension) you want to search in.
    -q, --query <query>                      String you want to search in the file.

A "poem.txt" document has been added as sample file in root directory.

Example usage (Ubuntu 18.04)

➜  minigrep_rust git:(master) ✗ cargo run -- --query the --filename poem.txt --case_sensitive n
   Compiling minigrep_rust v0.1.0 (/home/gurbaaz/rprojects/minigrep_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.60s
     Running `target/debug/minigrep_rust --query the --filename poem.txt --case_sensitive n`
Then there’s a pair of us - don’t tell!
They’d banish us, you know.
To tell your name the livelong day

Do star if you liked it or learnt something, and please 🙏 give suggestions for improvement, as working with Rust is surely rusty 😵(definitely for learners).

❤️

About

Rust implementation of the basic form of grep. Used CLAP for better argument parsing.


Languages

Language:Rust 100.0%