ripgrep-all/src/bin/rga.rs

30 lines
795 B
Rust
Raw Normal View History

2019-06-05 19:28:35 +00:00
use rga::adapters::*;
2019-06-04 18:08:26 +00:00
use std::process::Command;
fn main() -> std::io::Result<()> {
2019-06-05 19:28:35 +00:00
let adapters = get_adapters();
let extensions = adapters
.iter()
.flat_map(|a| &a.metadata().matchers)
.filter_map(|m| match m {
Matcher::FileExtension(ext) => Some(ext as &str),
})
.collect::<Vec<_>>()
.join(",");
2019-06-04 18:08:26 +00:00
let exe = std::env::current_exe().expect("Could not get executable location");
let preproc_exe = exe.with_file_name("rga-preproc");
let mut child = Command::new("rg")
2019-06-05 19:28:35 +00:00
.arg("--no-line-number")
2019-06-04 18:08:26 +00:00
.arg("--pre")
.arg(preproc_exe)
2019-06-05 19:28:35 +00:00
.arg("--pre-glob")
.arg(format!("*.{{{}}}", extensions))
2019-06-04 18:08:26 +00:00
.args(std::env::args().skip(1))
.spawn()?;
child.wait()?;
Ok(())
}