From 5cea749df6bd883af79c2c9aabbbbcd00c32ece3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=C3=A4rber?= <01mf02@gmail.com> Date: Tue, 14 Jan 2025 12:55:08 +0100 Subject: [PATCH] Shorten `--argjson` handling. --- jaq/src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jaq/src/main.rs b/jaq/src/main.rs index 38b60fc3..32c97043 100644 --- a/jaq/src/main.rs +++ b/jaq/src/main.rs @@ -137,10 +137,8 @@ fn binds(cli: &Cli) -> Result, Error> { let argjson = cli.argjson.iter().map(|(k, s)| { use hifijson::token::Lex; let mut lexer = hifijson::SliceLexer::new(s.as_bytes()); - let v = lexer - .exactly_one(Val::parse) - .map_err(|e| Error::Parse(format!("{e} (for value passed to `--argjson {k}`)"))); - Ok((k.to_owned(), v?)) + let err = |e| Error::Parse(format!("{e} (for value passed to `--argjson {k}`)")); + Ok((k.to_owned(), lexer.exactly_one(Val::parse).map_err(err)?)) }); let rawfile = cli.rawfile.iter().map(|(k, path)| { let s = std::fs::read_to_string(path).map_err(|e| Error::Io(Some(format!("{path:?}")), e));