Skip to content

v0.4.0

Choose a tag to compare

@github-actions github-actions released this 15 Sep 15:33
· 300 commits to main since this release
6136cd5

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 --each makes 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-error ends 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 command jz run started is stopped.
  • --format text, --format lines and --format nul read 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 as find -print0 writes them. Nothing is trimmed, empty records
    stay "", and a separator at the end does not add an empty record.
    --stream writes lines and nul records as they arrive.
  • --type COLUMN=TYPE converts a csv or tsv column to int, float or
    bool with 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=TEXT writes 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=PATH puts a file's text, or standard input's
    with -, into the JSON with every line ending kept. KEY=@PATH still
    drops the last one. Text that is not UTF-8 is exit 3.
  • jz new --path POINTER=VALUE places 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. --string and --text-file take 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:=3 is still the key spec.replicas.

Changed

  • jz --help groups 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 --help and jz new --help group theirs
    the same way. --raw is described as what it is, the text a definition
    cut without its field rules, and --extract and --exclude as 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=json example 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 new lines
    and nul) 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-error to end at the first as before.

Removed

  • Breaking: --yaml, which wrote the output as YAML, is gone from the
    default mode, jz run and jz new. jz writes JSON only, and a command
    line that still passes --yaml is 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 .yaml or .yml file, --format yaml, jz new key:=@file.yaml and definitions written in YAML all work as before.

Fixed

  • A csv or tsv read as data (--format csv, a .csv or .tsv file, 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 made 007 a number with --format csv and left
    it "007" with jz new; only --parser csv reads with it. --explain
    now says the file was read as csv rather than naming csv/comma.