Skip to content

Global Output Flag (structured JSON by default, GH CLI standard) #357

@script-this

Description

@script-this

Add a global --output / -o flag that controls the output format for all commands, replacing the current per-command -n (non-interactive) flag with a consistent, global mechanism.

Current State

The codebase already supports three output formats plus interactive TUI, implemented as per-resource rendering strategies:

  • Interactive (InteractiveRenderer) — Bubbletea TUI (default when stdout is a TTY)
  • Table (NonInteractiveRenderer) — tab-separated via tabwriter, toggled with -n
  • CSV (CsvRenderer) — comma-separated
  • JSON (JSONRenderer) — pretty-printed JSON

However, coverage is inconsistent — e.g. collection has all four strategies including JSON, while study only has Interactive, Table, and CSV (no JSON). Each resource also duplicates the rendering strategy implementations rather than sharing them.

Proposed Changes

  1. Global --output / -o flag with values: json (default for non-TTY), table, csv
    • Interactive/TUI mode remains the default when stdout is a TTY and no flag is specified
  2. Unified rendering strategies — extract shared Table, CSV, and JSON renderers so each resource doesn't duplicate the logic
  3. Consistent format support — ensure all resources support all output formats
  4. Align with GH CLI formatting conventions where practical

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions