You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-2Lines changed: 47 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,17 @@
1
1
# jetrocli
2
2
3
+
New to jetro? [**jetro-book**](https://mitghi.github.io/jetro-book/) is the best place to start — guide, tour, and documentation for learning the expression language.
4
+
3
5
<palign="center">
4
6
<imgsrc="media/jetrocli.png"alt="jetrocli">
5
7
</p>
6
8
7
-
Interactive split-pane TUI for [jetro](https://github.com/mitghi/jetro) — paste JSON, write expressions, see results live. Built on `ratatui` + `crossterm`.
8
9
9
-
New to jetro? [**jetro-book**](https://mitghi.github.io/jetro-book/) is the best place to start — guide, tour, and documentation for learning the expression language.
10
+
`jetrocli` is a terminal companion for [jetro](https://github.com/mitghi/jetro), a JSON expression language. It gives you two ways to work with JSON: an interactive TUI for exploring data and a command-line program for processing JSON in scripts, pipes, files, and NDJSON datasets.
11
+
12
+
Run it directly and it opens a split-pane JSON workbench: paste or load JSON, write a jetro expression, and see the result update live as you type. Pipe or redirect input and it skips the TUI, evaluates once, and prints the result like a regular Unix command.
13
+
14
+
For large files, `jetrocli` can memory map regular-file input. In `--ndjson` mode it scans one JSON document per line, supports reverse reads from the end of log-style files, and can stop early with `--limit` for bounded queries over very large datasets.
10
15
11
16
## Features
12
17
@@ -15,6 +20,11 @@ New to jetro? [**jetro-book**](https://mitghi.github.io/jetro-book/) is the best
15
20
-**Structural folding** in JSON editor. Fold any `{…}` / `[…]` block, with gutter triangles (`▾` / `▸`) and inline `⋯ N lines` markers.
16
21
-**Schema-aware completion** — suggests fields at the current path, auto-unwraps element fields inside array chains, filters builtins by receiver type.
17
22
-**Inline docs pane** next to completions — every jetro builtin ships with signature, summary, and example.
23
+
-**Pipe / batch mode without TUI** — when stdin is piped or redirected, jetrocli evaluates once and prints the result directly for shell workflows.
24
+
-**File-backed large JSON reads** — regular-file stdin is memory mapped for zero-copy loading instead of forcing the interactive path.
25
+
-**Fast NDJSON scans** — `--ndjson` evaluates one JSON document per line from `-i <FILE>` and emits one compact result per row.
26
+
-**Reverse NDJSON reads** — `--ndjson -r` scans from tail to head, useful for log-style files where the newest rows matter first.
27
+
-**Bounded NDJSON filters** — combine `--ndjson` with `--limit <N>` to stop after the first `N` emitted rows, including reverse scans for "latest matching rows" queries.
|`--reverse-chunk <BYTES>`| Reverse reader chunk size. Tune for very wide rows. |
94
104
105
+
## Performance
106
+
107
+
NDJSON mode is built for file-backed batch scans. It memory maps the input file, evaluates the expression independently for each line, and emits compact JSON results without starting the interactive TUI.
108
+
109
+
The repository includes a reproducible benchmark in `benchmark/`:
`benchmark/bench.sh` compares only the `jetrocli` and [`jaq`](https://github.com/01mf02/jaq) program. The generator writes roughly 1 GB of NDJSON shaped like:
In practice, expect NDJSON mode to be especially strong for field projection, string transforms, row-local indexing, and shallow array operations over large files. Queries that allocate larger derived arrays or inspect more nested values naturally move more bytes and take longer.
0 commit comments