Skip to content

Implement output formatters (table, JSON, CSV) with field selection #8

@ran-codes

Description

@ran-codes

Description

Build the output formatting layer that all commands will use. Supports table, JSON, and CSV output with TTY auto-detection and field selection.

Requirements

  • NFR-1.1: Every command supports --output json|table|csv
  • NFR-1.2: Default to table when stdout is TTY, json when piped
  • NFR-1.3: --fields flag to select specific columns
  • NFR-1.4: Errors output as structured JSON to stderr when --output json
  • Design Decision D-2: Output format auto-detection

Acceptance Criteria

  • internal/output/formatter.goFormatter interface with Format(data interface{}, format string, fields []string) (string, error)
  • internal/output/table.go — table formatter using olekukonez/tablewriter
  • internal/output/json.go — JSON formatter (pretty-print for TTY, compact for pipe)
  • internal/output/csv.go — CSV formatter with header row
  • TTY auto-detection using mattn/go-isatty
  • --fields parsing and column filtering
  • Unit tests for each formatter with sample data

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions