Skip to content

Commit 5cea749

Browse files
committed
Shorten --argjson handling.
1 parent 08ac834 commit 5cea749

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

jaq/src/main.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ fn binds(cli: &Cli) -> Result<Vec<(String, Val)>, Error> {
137137
let argjson = cli.argjson.iter().map(|(k, s)| {
138138
use hifijson::token::Lex;
139139
let mut lexer = hifijson::SliceLexer::new(s.as_bytes());
140-
let v = lexer
141-
.exactly_one(Val::parse)
142-
.map_err(|e| Error::Parse(format!("{e} (for value passed to `--argjson {k}`)")));
143-
Ok((k.to_owned(), v?))
140+
let err = |e| Error::Parse(format!("{e} (for value passed to `--argjson {k}`)"));
141+
Ok((k.to_owned(), lexer.exactly_one(Val::parse).map_err(err)?))
144142
});
145143
let rawfile = cli.rawfile.iter().map(|(k, path)| {
146144
let s = std::fs::read_to_string(path).map_err(|e| Error::Io(Some(format!("{path:?}")), e));

0 commit comments

Comments
 (0)