cli: Add --byte-range flag to query command

This commit is contained in:
Tuấn-Anh Nguyễn 2020-07-12 20:45:17 +07:00
parent 0c2dc4c1e9
commit c2fb0f5229
2 changed files with 15 additions and 1 deletions

View file

@ -9,6 +9,7 @@ pub fn query_files_at_paths(
paths: Vec<&Path>,
query_path: &Path,
ordered_captures: bool,
range: Option<(usize, usize)>,
) -> Result<()> {
let stdout = io::stdout();
let mut stdout = stdout.lock();
@ -20,6 +21,9 @@ pub fn query_files_at_paths(
.map_err(|e| Error::new(format!("Query compilation failed: {:?}", e)))?;
let mut query_cursor = QueryCursor::new();
if let Some((beg, end)) = range {
query_cursor.set_byte_range(beg, end);
}
let mut parser = Parser::new();
parser.set_language(language).map_err(|e| e.to_string())?;