Skip to content

feat(output): YAML/CSV formats + bare-array list payloads#1

Open
UnbreakableMJ wants to merge 1 commit into
mainfrom
feat/yaml-csv-list-output
Open

feat(output): YAML/CSV formats + bare-array list payloads#1
UnbreakableMJ wants to merge 1 commit into
mainfrom
feat/yaml-csv-list-output

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

  • Replace the --format yaml and --format csv stubs with dependency-free serializers over serde_json::Value.
  • yaml: block-style YAML 1.2 emitter with conservative scalar quoting (numbers, booleans, nulls, reserved words, colon/comment sequences, control chars). Validated against PyYAML.
  • csv: RFC 4180 writer; a single-key array wrapper (e.g. vpn status) unwraps into a table; nested values become lossless compact-JSON cells.
  • No new dependency: serde_yaml is deprecated and RUSTSEC-flagged, which would fail the mandatory cargo audit CI gate (Standard §3.3). The Value model is closed, so a small tested emitter suffices.
  • list subcommands now return a bare array as data instead of a single-key wrapper object, so --fields selects columns per record and --format jsonl streams one bare record per line (ACS §8).
  • Errors in yaml/csv mode emit structured JSON to stderr, matching json mode (PRD §9.7).

Behavior fixed

Behavior Before After
list --providers --json data {"providers":[…]} […] (metadata intact)
--fields on a list "data":{} (no-op) per-record column selection
--format jsonl one envelope line one record per line

Tests

  • Unit tests for the yaml/csv emitters and trim_payload.
  • Integration tests for the array-shaped list payload (--fields) and jsonl streaming.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, full cargo test (115 unit + 8 integration) all pass.

Note for review

jsonl now drops the per-line metadata envelope (NDJSON convention), which diverges from SFRS §6's "every response is Response<T>". Per-line envelopes would defeat the point of NDJSON; flag if strict envelope conformance is preferred instead.

🤖 Generated with Claude Code

Replace the `--format yaml` and `--format csv` stubs with dependency-free
serializers over serde_json::Value:

- yaml: block-style YAML 1.2 emitter with conservative scalar quoting
- csv: RFC 4180 writer; a single-key array wrapper unwraps into a table

Adding a YAML crate was avoided deliberately: serde_yaml is deprecated and
flagged by RUSTSEC, which would fail the mandatory cargo-audit CI gate
(Steelbore Standard §3.3). The Value model is closed, so a small tested
emitter suffices with zero dependency-audit surface.

List subcommands now return a bare array as `data` instead of a single-key
wrapper object, so `--fields` selects columns per record and `--format jsonl`
streams one bare record per line (ACS §8). Errors in yaml/csv mode emit
structured JSON to stderr, matching json mode (PRD §9.7).

Adds unit tests for the yaml/csv emitters and trim_payload, plus integration
tests for the array-shaped list payload and jsonl streaming.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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