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
- 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
- Unified rendering strategies — extract shared Table, CSV, and JSON renderers so each resource doesn't duplicate the logic
- Consistent format support — ensure all resources support all output formats
- Align with GH CLI formatting conventions where practical
Add a global
--output/-oflag 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:
InteractiveRenderer) — Bubbletea TUI (default when stdout is a TTY)NonInteractiveRenderer) — tab-separated viatabwriter, toggled with-nCsvRenderer) — comma-separatedJSONRenderer) — pretty-printed JSONHowever, coverage is inconsistent — e.g.
collectionhas all four strategies including JSON, whilestudyonly has Interactive, Table, and CSV (no JSON). Each resource also duplicates the rendering strategy implementations rather than sharing them.Proposed Changes
--output/-oflag with values:json(default for non-TTY),table,csv