rahat3062_minigrep

Crates.iorahat3062_minigrep
lib.rsrahat3062_minigrep
version0.1.3
sourcesrc
created_at2024-04-30 16:16:01.31042
updated_at2024-04-30 17:02:04.694582
descriptionA light-weight & minimal implementation of the grep cli app.
homepage
repository
max_upload_size
id1225223
size16,977
Rahat Bin Taleb (ToxicalNoob3062)

documentation

https://docs.rs/rahat3062_minigrep/0.1.3/rahat3062_minigrep/

README

rahat3062_minigrep

rahat3062_minigrep is a light-weight and minimal implementation of the grep command-line application. It is written in Rust and can be used both as a standalone application and as a library for other Rust programs.

Binary Crate

install via:

cargo install rahat3062_minigrep && \
alias minigrep = rahat3062_minigrep

The binary crate provides a command-line interface to the grep functionality. You can use it to search for a string in a file. Here's how to run it:

minigrep <query> <filename> -s

Replace with the string you want to search for and with the path to the file you want to search in and use -s for sensitive search.

If needed you can also take input from the stdin via pipelining:

history | minigrep cargo

Library Crate

The library crate provides a run function that you can use to perform a grep search programmatically. Here's an example:

use rahat3062_minigrep::{Config, run};

let config = Config {
    query: "my query".to_string(),
    filename: Some("my_file.txt".to_string()),
    sensitive: false,
};

let result = run(config);

In this example, run searches for "my query" in "my_file.txt" and returns the matching lines. The search is case-insensitive because sensitive is false.

Commit count: 0

cargo fmt