Add --row-range, --quiet, and --time flags to query subcommand
This commit is contained in:
parent
125503ff3b
commit
ff2436a6f8
2 changed files with 73 additions and 34 deletions
|
|
@ -3,6 +3,7 @@ use clap::{App, AppSettings, Arg, SubCommand};
|
|||
use glob::glob;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{env, fs, u64};
|
||||
use tree_sitter::Point;
|
||||
use tree_sitter_cli::parse::ParseOutput;
|
||||
use tree_sitter_cli::{
|
||||
generate, highlight, logger, parse, playground, query, tags, test, test_highlight, test_tags,
|
||||
|
|
@ -173,6 +174,8 @@ fn run() -> Result<()> {
|
|||
.index(1)
|
||||
.required(true),
|
||||
)
|
||||
.arg(&time_arg)
|
||||
.arg(&quiet_arg)
|
||||
.arg(&paths_file_arg)
|
||||
.arg(&paths_arg.clone().index(2))
|
||||
.arg(
|
||||
|
|
@ -181,6 +184,12 @@ fn run() -> Result<()> {
|
|||
.long("byte-range")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("row-range")
|
||||
.help("The range of rows in which the query will be executed")
|
||||
.long("row-range")
|
||||
.takes_value(true),
|
||||
)
|
||||
.arg(&scope_arg)
|
||||
.arg(Arg::with_name("captures").long("captures").short("c"))
|
||||
.arg(Arg::with_name("test").long("test")),
|
||||
|
|
@ -456,6 +465,8 @@ fn run() -> Result<()> {
|
|||
|
||||
("query", Some(matches)) => {
|
||||
let ordered_captures = matches.values_of("captures").is_some();
|
||||
let quiet = matches.values_of("quiet").is_some();
|
||||
let time = matches.values_of("time").is_some();
|
||||
let paths = collect_paths(matches.value_of("paths-file"), matches.values_of("paths"))?;
|
||||
let loader_config = config.get()?;
|
||||
loader.find_all_languages(&loader_config)?;
|
||||
|
|
@ -465,9 +476,17 @@ fn run() -> Result<()> {
|
|||
matches.value_of("scope"),
|
||||
)?;
|
||||
let query_path = Path::new(matches.value_of("query-path").unwrap());
|
||||
let range = matches.value_of("byte-range").map(|br| {
|
||||
let r: Vec<&str> = br.split(":").collect();
|
||||
r[0].parse().unwrap()..r[1].parse().unwrap()
|
||||
let byte_range = matches.value_of("byte-range").and_then(|arg| {
|
||||
let mut parts = arg.split(":");
|
||||
let start = parts.next()?.parse().ok()?;
|
||||
let end = parts.next().unwrap().parse().ok()?;
|
||||
Some(start..end)
|
||||
});
|
||||
let point_range = matches.value_of("row-range").and_then(|arg| {
|
||||
let mut parts = arg.split(":");
|
||||
let start = parts.next()?.parse().ok()?;
|
||||
let end = parts.next().unwrap().parse().ok()?;
|
||||
Some(Point::new(start, 0)..Point::new(end, 0))
|
||||
});
|
||||
let should_test = matches.is_present("test");
|
||||
query::query_files_at_paths(
|
||||
|
|
@ -475,8 +494,11 @@ fn run() -> Result<()> {
|
|||
paths,
|
||||
query_path,
|
||||
ordered_captures,
|
||||
range,
|
||||
byte_range,
|
||||
point_range,
|
||||
should_test,
|
||||
quiet,
|
||||
time,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue