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
Dependencies
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
--output json|table|csvtablewhen stdout is TTY,jsonwhen piped--fieldsflag to select specific columns--output jsonAcceptance Criteria
internal/output/formatter.go—Formatterinterface withFormat(data interface{}, format string, fields []string) (string, error)internal/output/table.go— table formatter usingolekukonez/tablewriterinternal/output/json.go— JSON formatter (pretty-print for TTY, compact for pipe)internal/output/csv.go— CSV formatter with header rowmattn/go-isatty--fieldsparsing and column filteringDependencies
github.com/olekukonez/tablewriter,github.com/mattn/go-isatty