Skip to content

Commit d5742e0

Browse files
authored
feat(cli): add structured output to list commands (#3067)
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
1 parent a4f9c76 commit d5742e0

10 files changed

Lines changed: 765 additions & 36 deletions

File tree

.agents/skills/openshell-cli/SKILL.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,15 @@ provider instead of passing API keys, tokens, or other secrets to `sandbox exec`
333333

334334
```bash
335335
openshell sandbox provider list my-sandbox
336+
openshell sandbox provider list my-sandbox --output json
336337
openshell sandbox provider attach my-sandbox my-github
337338
openshell sandbox provider detach my-sandbox my-github
338339
```
339340

341+
Structured attachment output contains provider names, types, and sorted
342+
credential and config key names. It never contains credential, handle, or
343+
config values.
344+
340345
### View logs
341346

342347
```bash
@@ -498,6 +503,7 @@ View all revisions to understand how the policy evolved:
498503

499504
```bash
500505
openshell policy list dev --limit 50
506+
openshell policy list dev --output json
501507
```
502508

503509
Fetch a specific historical revision:
@@ -576,6 +582,17 @@ openshell sandbox delete my-app
576582
openshell sandbox create --from ./Dockerfile --name my-app --forward 8080
577583
```
578584

585+
Use structured output when automation needs the tracked forward metadata and
586+
validated process state:
587+
588+
```bash
589+
openshell forward list --output json
590+
```
591+
592+
Each record includes `sandbox`, `bind_address`, `port`, `pid`, and `alive`.
593+
The `alive` boolean validates the tracked process identity; it does not probe
594+
the forwarded socket.
595+
579596
Create and forward in one command:
580597

581598
```bash
@@ -738,6 +755,7 @@ openshell forward service my-app --target-port 8000 --local 127.0.0.1:0
738755
# Expose and manage an HTTP service through the gateway.
739756
openshell service expose my-app 8080 web
740757
openshell service list my-app
758+
openshell service list my-app --output json
741759
openshell service get my-app web
742760
openshell service delete my-app web
743761
```

.agents/skills/openshell-cli/cli-reference.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,25 @@ openshell
5757
│ ├── download <name> <path> [dest]
5858
│ ├── ssh-config [name]
5959
│ └── provider
60-
│ ├── list [name]
60+
│ ├── list [name] [-o table|yaml|json]
6161
│ ├── attach <name> <provider>
6262
│ └── detach <name> <provider>
6363
├── forward
6464
│ ├── start <port> [name] [-d]
6565
│ ├── stop <port> [name]
66-
│ ├── list
66+
│ ├── list [-o table|yaml|json]
6767
│ └── service [name] --target-port <port> [opts]
6868
├── service
6969
│ ├── expose <sandbox> <target-port> [service]
70-
│ ├── list [sandbox]
70+
│ ├── list [sandbox] [-o table|yaml|json]
7171
│ ├── get <sandbox> [service]
7272
│ └── delete <sandbox> [service]
7373
├── logs [name] [opts]
7474
├── policy
7575
│ ├── set [name] --policy <path> [--global] [--wait]
7676
│ ├── update [name] [opts]
7777
│ ├── get [name] [--full|--base] [--global]
78-
│ ├── list [name] [--global]
78+
│ ├── list [name] [--global] [-o table|yaml|json]
7979
│ ├── delete --global
8080
│ └── prove --policy <path> --credentials <path> [opts]
8181
├── settings
@@ -107,6 +107,15 @@ openshell
107107
│ │ └── delete <id>
108108
│ ├── update <name> [opts]
109109
│ └── delete <name>...
110+
├── workspace
111+
│ ├── create <name>
112+
│ ├── get <name>
113+
│ ├── list [opts]
114+
│ ├── delete <name>...
115+
│ └── member
116+
│ ├── add --workspace <name> --subject <subject> --role <role>
117+
│ ├── remove --workspace <name> --subject <subject>
118+
│ └── list --workspace <name> [-o table|yaml|json]
110119
├── doctor
111120
│ └── check
112121
├── term
@@ -321,10 +330,13 @@ Print an SSH config `Host` block. The name defaults to the last-used sandbox.
321330

322331
Manage providers on an existing sandbox:
323332

324-
- `openshell sandbox provider list [name]`
333+
- `openshell sandbox provider list [name] [--output table|yaml|json]`
325334
- `openshell sandbox provider attach <name> <provider>`
326335
- `openshell sandbox provider detach <name> <provider>`
327336

337+
Structured list output contains `name`, `type`, and sorted `credential_keys`
338+
and `config_keys` arrays. It excludes all credential, handle, and config values.
339+
328340
---
329341

330342
## Port Forwarding Commands
@@ -343,9 +355,15 @@ Start forwarding a local port to a sandbox.
343355

344356
Stop a background port forward. When the sandbox name is omitted, it is inferred from active forwards.
345357

346-
### `openshell forward list`
358+
### `openshell forward list [--output table|yaml|json]`
347359

348-
List all active port forwards (sandbox, port, PID, status).
360+
List all tracked port forwards. Table output shows the sandbox, bind address,
361+
port, PID, and status. JSON and YAML output expose `sandbox`, `bind_address`,
362+
`port`, `pid`, and the boolean `alive`; an empty result is an empty collection.
363+
364+
| Flag | Default | Description |
365+
|------|---------|-------------|
366+
| `-o`, `--output <FORMAT>` | `table` | Output format: `table`, `yaml`, or `json` |
349367

350368
### `openshell forward service [name] --target-port <port>`
351369

@@ -364,10 +382,13 @@ Forward a local TCP port to a loopback service inside a sandbox over the gRPC re
364382
Gateway-managed HTTP service endpoints:
365383

366384
- `openshell service expose <sandbox> <target-port> [service]`
367-
- `openshell service list [sandbox] [--limit N] [--offset N]`
385+
- `openshell service list [sandbox] [--limit N] [--offset N] [--output table|yaml|json]`
368386
- `openshell service get <sandbox> [service]`
369387
- `openshell service delete <sandbox> [service]`
370388

389+
Structured list records contain `workspace`, `sandbox`, `service`,
390+
`target_port`, and `url`. Empty lists serialize as empty collections.
391+
371392
---
372393

373394
## Logs Command
@@ -454,6 +475,11 @@ List policy revision history (version, hash, status, created, error).
454475
|------|---------|-------------|
455476
| `--limit <N>` | 20 | Max revisions to return |
456477
| `--global` | false | List global policy revisions |
478+
| `-o`, `--output <FORMAT>` | `table` | Output format: `table`, `yaml`, or `json` |
479+
480+
Structured records use the policy metadata contract from `policy get`: scope,
481+
sandbox when applicable, version, full hash, normalized status, and available
482+
timestamps, load error, and provenance.
457483

458484
### `openshell policy delete --global`
459485

@@ -486,6 +512,16 @@ Sandbox names default to the last-used sandbox. The CLI fetches and submits each
486512

487513
---
488514

515+
## Workspace Member Commands
516+
517+
### `openshell workspace member list --workspace <name>`
518+
519+
List workspace members. Add `--output table|yaml|json` to select the format.
520+
Structured records contain `subject` and a normalized `role` of `admin`,
521+
`user`, or `unknown`; empty lists serialize as empty collections.
522+
523+
---
524+
489525
## Settings Commands
490526

491527
Settings support sandbox and gateway-global scopes:

0 commit comments

Comments
 (0)