From e2de738026c481d8e7fa3981dd8e8174e44b929f Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Thu, 19 Aug 2021 08:21:16 +0300 Subject: [PATCH] cli(query): Improve and unify query subcommand output --- cli/src/query.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cli/src/query.rs b/cli/src/query.rs index 9039f751..73d6dd28 100644 --- a/cli/src/query.rs +++ b/cli/src/query.rs @@ -48,10 +48,12 @@ pub fn query_files_at_paths( let capture_name = &query.capture_names()[capture.index as usize]; writeln!( &mut stdout, - " pattern: {}, capture: {}, row: {}, text: {:?}", + " pattern: {:>2}, capture: {} - {}, start: {}, end: {}, text: `{}`", mat.pattern_index, + capture.index, capture_name, - capture.node.start_position().row, + capture.node.start_position(), + capture.node.end_position(), capture.node.utf8_text(&source_code).unwrap_or("") )?; results.push(query_testing::CaptureInfo { @@ -70,9 +72,11 @@ pub fn query_files_at_paths( if end.row == start.row { writeln!( &mut stdout, - " capture: {}, start: {}, text: {:?}", + " capture: {} - {}, start: {}, end: {}, text: `{}`", + capture.index, capture_name, start, + end, capture.node.utf8_text(&source_code).unwrap_or("") )?; } else {