Skip to content

[Hackathon] feat(cli): add --output csv and --output ndjson for list commands #164

Closed as not planned

Description

@crypticsaiyan

Discord Username / User ID

uisupersaiyan3

What does this improvement do?

The only machine-readable output today is --output json, which for the paginated list surfaces emits a single buffered, pretty-printed array (out.print({ runs, nextCursor }, ...) in runResultHistory at src/commands/test.ts:3735, test runList at :419, project runList at src/commands/project.ts:47). That shape is awkward for the two most common scripting consumers: spreadsheets and awk (must hand-parse JSON), and line-oriented pipelines (jq or while read must buffer and slice the whole array). This adds two modes to the existing --output enum. --output csv emits an RFC 4180 table: a header row, then one row per item, with columns derived from the response type so they cannot drift. --output ndjson emits one compact JSON object per line with no wrapping array, streamed as each page arrives, so ... --output ndjson | jq -c 'select(.status=="failed")' works without buffering. Both apply to the list commands only (test result --history, project list, test list); a single-object command given --output csv or --output ndjson exits 5 with a clear message. It drops straight into shell CI and data pipelines.

Details / implementation notes

Extend OutputMode (src/lib/output.ts:1) to 'json' | 'text' | 'csv' | 'ndjson' and widen isOutputMode (:12); because --output is validated at one choke point (src/index.ts:128, :140) the new modes stay uniform across command groups. Reuse (do not re-implement) the existing render call sites: runResultHistory (src/commands/test.ts:3735, table via renderRunHistoryTable :3860), test runList (:419, renderTestListText :473), project runList (src/commands/project.ts:47), by adding csv and ndjson branches alongside the current json/text branch in each. Row columns come from the source-of-truth types (RunHistoryItem, CliTest, CliProject), never hand-listed. csv quoting follows RFC 4180 (fields containing , " or a newline are wrapped, " is doubled; null/absent renders as an empty field). ndjson writes one line per row incrementally across the existing cursor loop and routes pagination metadata (nextCursor, short-page hints) to stderr so stdout stays pure ndjson. --output json and --output text remain byte-identical; exit codes are unchanged except exit 5 when csv or ndjson is used on a non-list command. No new dependency. Tests: csv quoting edge cases, multi-page accumulation, ndjson line shape, stdout/stderr separation, non-list rejection exit 5, json/text unchanged. PR to follow once assigned.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Jul 3, 2026
  2. ISTHA1607 commented on Jul 23, 2026

    @ISTHA1607

    /assign

  3. added
    in-progress
    and removed
    needs-triage
    on Jul 23, 2026
  4. testsprite-hob commented on Jul 23, 2026

    @testsprite-hob

    Assigned to @ISTHA1607. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

  5. added
    accepted
    on Aug 13, 2026
  6. crypticsaiyan commented on Oct 21, 2026

    @crypticsaiyan
    ContributorAuthor

    /assign

  7. testsprite-hob commented on Oct 21, 2026

    @testsprite-hob

    Assigned to @crypticsaiyan. Thanks for taking this on. (1 more slot available.)

    Your open assigned issues (2/3):

  8. zeshi-du commented on Nov 9, 2026

    @zeshi-du
    Contributor

    We've decided not to add new output formats in this cycle; --output stays json and text (see #632). Thanks for the proposal and the work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

acceptedhackathonin-progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions