Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search: add --preview-match option #1785

Merged
merged 3 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
seach: improve usage text re --preview-match; microoptimize previ…
…ew timeout init

[skip ci]
  • Loading branch information
jqnatividad committed May 1, 2024
commit 31b794449ffc85b2da3442ca548103425de5939f
4 changes: 2 additions & 2 deletions src/cmd/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ search options:
No output is produced.
--preview-match <arg> Preview the first <arg> matches or all the matches found in
<arg> milliseconds, whichever occurs first. Returns the preview
to stderr. Output is still written to stdout.
to stderr. Output is still written to stdout or --output as usual.
-c, --count Return number of matches to stderr.
--size-limit <mb> Set the approximate size limit (MB) of the compiled
regular expression. If the compiled expression exceeds this
Expand Down Expand Up @@ -171,8 +171,8 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
}

let mut preview_match_ctr = 0;
let start_time = std::time::Instant::now();
let preview_timeout = std::time::Duration::from_millis(preview_match as u64);
let start_time = std::time::Instant::now();
while rdr.read_byte_record(&mut record)? {
row_ctr += 1;
m = sel.select(&record).any(|f| pattern.is_match(f));
Expand Down