Skip to content

feat(pretty): table shallow nested records - #3

Merged
natalie-o-perret merged 5 commits into
mainfrom
feat/pretty-nested-record-tables
Sep 29, 2026
Merged

natalie-o-perret merged 5 commits into
mainfrom
feat/pretty-nested-record-tables

Conversation

@natalie-o-perret

Copy link
Copy Markdown
Owner

Summary

  • flattens consistent shallow nested records into readable table columns
  • keeps deep, irregular, ambiguous, or overly wide records as lossless trees
  • adds nested_records: auto|table|tree configuration via feat(plugin): forward formatter configuration rest-sh/restish#446
  • keeps memory units and terminal-width handling consistent across tables and trees

Configuration

{
  "plugins": {
    "pretty": {
      "nested_records": "auto"
    }
  }
}

auto is width-aware, table ignores width heuristics when flattening is structurally safe, and tree keeps nested records as Item N branches. Older Restish hosts omit the config and therefore use auto.

Example

From pretty/, build and install the baseline or branch version, then serve the included fixture in another terminal:

go build -o /tmp/restish-pretty .
restish plugin install /tmp/restish-pretty --yes
python3 -m http.server 8765 --bind 127.0.0.1

Run the same command at 120 columns:

stty cols 120
restish get http://127.0.0.1:8765/examples/nested-records.json -o pretty --rsh-print b

Before, the nested records render as repeated branches:

Items
├── Item 1
│   ├── Id: node-a
│   ├── Capacity
│   │   ├── Cpu
...

After, repeated fields become columns and constants stay in Details:

Details
├── State: ready
│
├────────────┬────────────┬───────────────────────┬──────────────┬────────┬───────╮
│ Capacity   │ Capacity   │ Capacity Memory Total │ Cluster Name │ Id     │ Name  │
│  Cpu Total │   Cpu Used │                       │              │        │       │
├────────────┼────────────┼───────────────────────┼──────────────┼────────┼───────┤
│        100 │         40 │                 8 GiB │ Primary      │ node-a │ Alpha │
...

Note

AI assistance: documentation, test scaffolding, PR description.

@natalie-o-perret
natalie-o-perret force-pushed the feat/pretty-nested-record-tables branch from 340cec1 to 1214c11 Compare September 29, 2026 13:21
@natalie-o-perret
natalie-o-perret merged commit 66d5461 into main Sep 29, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant