Expand description
ยงSimpleGrep ๐ต๏ธโโ๏ธ๐
simple_grep
is a simple command-line tool written in Rust to search for lines
that contain a specific query string in a given text file, similar to Unix grep
.
It supports both case-sensitive and case-insensitive search based on the
IGNORE_CASE
environment variable.
ยงExample
cargo run -- <query> <file_path>
Case-insensitive search:
IGNORE_CASE=1 cargo run -- <query> <file_path>
ยงCrate Structure
Config
struct handles argument parsing and configuration.run
function executes the main logic.search
andsearch_case_insensitive
perform line matching.
Structsยง
- Config
- Holds the configuration parameters for the SimpleGrep application.
Functionsยง
- run
- Executes the main logic of SimpleGrep: reads the file, searches for the query, and prints matching lines to stdout.
- search
- Performs a case-sensitive search of
query
incontents
. - search_
case_ insensitive - Performs a case-insensitive search of
query
incontents
.