ripgrep: add --line-buffered and --block-buffered

These flags provide granular control over ripgrep's buffering strategy.
The --line-buffered flag can be genuinely useful in certain types of shell
pipelines. The --block-buffered flag has a murkier use case, but we add it
for completeness.
This commit is contained in:
Andrew Gallant
2018-09-04 21:39:05 -04:00
parent 4846d63539
commit b6e30124e0
4 changed files with 79 additions and 1 deletions

View File

@@ -314,7 +314,14 @@ impl Args {
/// Execute the given function with a writer to stdout that enables color
/// support based on the command line configuration.
pub fn stdout(&self) -> cli::StandardStream {
cli::stdout(self.matches().color_choice())
let color = self.matches().color_choice();
if self.matches().is_present("line-buffered") {
cli::stdout_buffered_line(color)
} else if self.matches().is_present("block-buffered") {
cli::stdout_buffered_block(color)
} else {
cli::stdout(color)
}
}
/// Return the type definitions compiled into ripgrep.