Output Formatting
Every command's output goes through the same pipe pipeline, whether you're poking around interactively or scripting against ze. One operator set, three ways to use it: set a persistent default, pipe it inline, or apply it offline to already-captured output.
The simple way: set a default once
set cli format <name> in the interactive CLI picks a default so every
command already displays that way, with no piping needed at all:
set cli format table
set cli format # shows the current default
| Format | Description |
|---|---|
text |
Space-aligned columns, no box-drawing (default) |
table |
Box-drawing table |
json |
Pretty-printed JSON |
yaml |
YAML output |
ndjson |
One compact JSON object per line |
The choice persists for the session via the ze.cli.format setting; it can
also be set permanently through YANG config.
Piping inline
Append | <operator> to any command, shell-like:
show bgp peer list | table
show bgp peer list | json compact
show bgp rib | match established
show bgp peer list | first 5
Only one format operator (json, ndjson, table, text, yaml) is
allowed per chain; combining two is rejected. Filter and display operators
chain freely.
| Operator | Kind | Description |
|---|---|---|
table |
format | Box-drawing table rendering |
text |
format | Space-aligned columns, no box-drawing |
json [compact] |
format | Pretty (default) or compact JSON |
ndjson |
format | One compact JSON object per line |
yaml |
format | YAML output |
match <pattern> |
filter | Case-insensitive grep on output lines |
count |
filter | Count items (JSON-aware: array length or map size) |
first <n> / last <n> |
filter | Take first or last N items |
resolve |
display | Add reverse DNS names for IP address values |
origin |
display | Add ASN and network name for IP address values |
log |
display | Append each update instead of replacing (monitor commands) |
| β | display | Disable paging (currently a no-op) |
The offline way: ze format
Scripts and pipelines outside an interactive session apply the same
operators to any captured JSON via ze format:
ze show host cpu | ze format table
ze debug show | ze format match reactor
ze debug show | ze format count
ze show bgp peer list | ze format yaml
ze show bgp peer list | ze format first 5
ze format reads stdin (up to 256 MB), applies the pipe chain given as
arguments, and writes the result to stdout. It's the same operator table
above, minus the display-only operators that only make sense inside a live
session (log, no-more).
Command-specific filters
Some commands extend the generic set with their own filter vocabulary,
folded into the command itself rather than staying client-side. show bgp
rib, for example, adds:
| Filter | Description |
|---|---|
received / advertised |
Select the Adj-RIB-In or Adj-RIB-Out side |
peer <selector> |
Filter by peer |
family <afi/safi> |
Filter by address family |
prefix <pattern> |
Filter by prefix |
path <pattern> |
Filter by AS path |
community <value> |
Filter by standard community |
match <pattern> |
Cross-field structured match |
count |
Count matching routes without serializing rows |
first <n> / last <n> |
Take first or last N routes |
prefix-summary |
Summarize by family and prefix length |
graph |
Render an AS-path topology graph (box-drawing) |
reason |
Explain best-path selection (show bgp rib best only) |
These are parsed and validated the same way as generic pipes, but resolved
into command arguments before the command runs, rather than filtering
output afterward -- so show bgp rib | peer 10.0.0.1 | count counts only
that peer's routes server-side instead of fetching everything and counting
client-side.