diff options
author | Joursoir <chat@joursoir.net> | 2023-03-03 00:00:55 +0400 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2023-03-03 00:19:02 +0400 |
commit | 0fd76b8e90470b99f3e5c968b65562fde56d0c3e (patch) | |
tree | 1c2009dc3d857a12b02a3bbb5f0bb19f780b4dc9 /src/main.rs | |
parent | c15d3215dea3dadf93c1be1291c4001c3bff8f4e (diff) | |
download | trgrep-0fd76b8e90470b99f3e5c968b65562fde56d0c3e.tar.gz trgrep-0fd76b8e90470b99f3e5c968b65562fde56d0c3e.tar.bz2 trgrep-0fd76b8e90470b99f3e5c968b65562fde56d0c3e.zip |
add option to match only whole words
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 3111766..33de082 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,10 @@ struct Config { /// Ignores the case of the search string #[arg(short, long)] ignore_case: bool, + + /// Matches only whole words + #[arg(short, long)] + word_regexp: bool, } fn main() { @@ -48,7 +52,7 @@ fn run(config: Config) -> Result<(), Box<dyn Error>> { }; for line in reader.lines().map(|l| l.unwrap()) { - if !trgrep::contains_pattern(&line, &config.pattern, config.ignore_case) { + if !trgrep::contains_pattern(&line, &config.pattern, config.ignore_case, config.word_regexp) { continue; } println!("{line}"); |