Omit files and print only match options added
These are essential for using the tool for scripting purposes.
This commit is contained in:
@@ -43,15 +43,21 @@ impl<'a> Printer for SimplePrinter<'a> {
|
||||
|
||||
impl<'a> SimplePrinter<'a> {
|
||||
fn print_file_name(&self) {
|
||||
println!("{}:", self.file_match.file_name);
|
||||
if !self.config.omit_filenames {
|
||||
println!("{}:", self.file_match.file_name);
|
||||
}
|
||||
}
|
||||
|
||||
fn print_linenumber(&self, mat: &Match) {
|
||||
print!("{}: ", mat.line_number);
|
||||
if !self.config.omit_filenames {
|
||||
print!("{}: ", mat.line_number);
|
||||
}
|
||||
}
|
||||
|
||||
fn print_first_part_of_line(&self, mat: &Match, current_position: usize, match_start: usize) {
|
||||
print!("{}", mat.text.get(current_position..match_start).unwrap());
|
||||
if !self.config.match_only {
|
||||
print!("{}", mat.text.get(current_position..match_start).unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
fn print_match(&self, mat: &Match, index: &MatchIndex) {
|
||||
@@ -59,7 +65,11 @@ impl<'a> SimplePrinter<'a> {
|
||||
}
|
||||
|
||||
fn print_end_of_line(&self, mat: &Match, index: &MatchIndex) {
|
||||
println!("{}", mat.text.get(index.end..mat.text.len()).unwrap());
|
||||
if !self.config.match_only {
|
||||
println!("{}", mat.text.get(index.end..mat.text.len()).unwrap());
|
||||
} else {
|
||||
println!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user