From cf418ce76679f019834e4b6ff2cbafc6d40c180e Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 16 Apr 2024 20:18:00 +0200 Subject: produces & print errors for unknown query constructs Not sure yet if i'll keep the printing code, it's kinda fragile & there's almost definitely a crate which i could use instead. --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 54f17a5..2a4898d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,7 @@ fn parse_nexp(path: &PathBuf) -> anyhow::Result<(String, rnix::Root)> { Ok((content, parse.tree())) } + fn main() { let args = Args::parse(); @@ -51,13 +52,15 @@ fn main() { let query = match parse.to_query() { Err(es) => { - eprintln!("{}", es.join("\n")); + queries::print_query_errors(&args.query, es); exit(1); }, Ok(query) => query }; - // println!("{nexp:#?}"); + if args.debug { + println!("{query:?}"); + } if args.batchmode { batchmode::batchmode(args.path, query, args.debug); @@ -196,7 +199,7 @@ fn surrounding_noise(node: &rnix::SyntaxNode) -> (NixNodeOrToken, NixNodeOrToken fn remove_node(node: &rnix::SyntaxNode) -> (usize, usize) { let (before, after) = surrounding_noise(node); - let (mut prev, mut next) = + let (mut prev, /*mut*/ next) = eat_whitespace(&before, &after); // println!("{prev:?}, {next:?}"); -- cgit v1.2.3