v0.4.0
jz is the step that makes JSON for the next command. jz new places
strings, file text and JSON values at keys or JSON Pointers, and makes one
document per line of standard input with --each; plain text reads as
strings with --format text, lines and nul; a csv or tsv column
takes a type with --type. --yaml output is removed. The registry is
unchanged at 224 commands and 596 definitions.
Added
jz new --eachmakes one document per line of standard input and
writes each as a line of JSON when its line has come, holding nothing
else of the input:vmstat 1 | jz --stream | jz new --each host=a sample:=@-.KEY:=@-is the line read as JSON,KEY=@-the line as a
string, and the files the other arguments name are read once. A line
that cannot be read is reported and left out, with the status 3.--stop-on-errorends a stream (--stream,jz run --stream,jz new --each) at the first record it cannot read, keeping the records written
before it, with the status 3; a commandjz runstarted is stopped.--format text,--format linesand--format nulread input that
has no format of its own as strings: the whole input as one string, a
list with one string per line (LF or CRLF), or one per NUL-terminated
record asfind -print0writes them. Nothing is trimmed, empty records
stay"", and a separator at the end does not add an empty record.
--streamwriteslinesandnulrecords as they arrive.--type COLUMN=TYPEconverts a csv or tsv column toint,floator
boolwith the rules a definition's field of that type follows; an
empty value is null and the other columns stay text. A value that is
not the type is exit 3 with the line and the column, and a column the
input does not have is exit 2.jz new --string KEY=TEXTwrites TEXT as a string exactly as it is, so
a value from a variable is never read as a file name (@...) or JSON,
whatever it holds:jz new --string "message=$MESSAGE".jz new --text-file KEY=PATHputs a file's text, or standard input's
with-, into the JSON with every line ending kept.KEY=@PATHstill
drops the last one. Text that is not UTF-8 is exit 3.jz new --path POINTER=VALUEplaces a value at a JSON Pointer with
the operators a plain argument has (=,:=,=@,:=@), making the
objects and arrays on the way;-appends and an index names an
element already given.--stringand--text-filetake a pointer in
place of a key. A location given twice, a pointer into a value given
whole, a key in an array and an index past the end are exit 2 before
anything is read.spec.replicas:=3is still the keyspec.replicas.
Changed
jz --helpgroups the options under Input, Output and the parser of
command output, says what jz is for in one line, and shows examples of
every source of JSON;jz run --helpandjz new --helpgroup theirs
the same way.--rawis described as what it is, the text a definition
cut without its field rules, and--extractand--excludeas keeping
and dropping keys of each object.- The README, the landing page and the usage guide describe jz as the
step that makes JSON for the next command, and every jz command they
show with its output is run by the end-to-end suite
(e2e/atago/docs.atago.yaml); a test fails when a page shows one that
no scenario runs. The--explain=jsonexample said the df capture had
8 lines read, where 7 are read and one is left out. - A data file read with
--stream(jsonl,ltsv, and the newlines
andnul) leaves out a record it cannot read and goes on, as a stream
of a command's output does, where it ended at the first. The status is
still 3. Pass--stop-on-errorto end at the first as before.
Removed
- Breaking:
--yaml, which wrote the output as YAML, is gone from the
default mode,jz runandjz new. jz writes JSON only, and a command
line that still passes--yamlis refused with exit status 2 and a
message saying so, before anything is read or run. To keep getting
YAML, pipe the JSON to a YAML tool:df -h | jz | yq -P. With
--stream, read the JSON Lines one document at a time. Reading YAML is
unchanged: a.yamlor.ymlfile,--format yaml,jz new key:=@file.yamland definitions written in YAML all work as before.
Fixed
- A csv or tsv read as data (
--format csv, a.csvor.tsvfile,jz new key:=@file.csv) keeps what it holds: an escape sequence stays in
its value, where it was taken off as colour, and a line of spaces is a
row, where it was dropped (printf 'key\n \nx\n' | jz --format csv
gave one row). A csv definition in the user registry no longer changes
such a reading, which made007a number with--format csvand left
it"007"withjz new; only--parser csvreads with it.--explain
now says the file was read as csv rather than namingcsv/comma.