Skip to content

Add --output flag for json/table/raw modes #14

@joelhooks

Description

@joelhooks

Problem

Currently output is JSON-only. Humans want pretty tables, scripts want raw values for piping.

Pattern from Go CLI Books

From "Building Modern CLI Applications in Go" (p.250-258):

type OutputFormatter interface {
    Format(data interface{}) (string, error)
}

type JSONFormatter struct{}
type TableFormatter struct{}
type RawFormatter struct{}

// Auto-detect based on TTY
if isatty.IsTerminal(os.Stdout.Fd()) {
    return TableFormatter{}
}
return JSONFormatter{}

Action Items

  • Add --output flag to root command (json|table|raw)
  • Create formatters in internal/output/
  • Auto-detect TTY for default mode
  • Update all commands to use formatter interface

Examples

secrets status --output json   # Structured JSON
secrets status --output table  # Pretty tables
secrets status --output raw    # Just values
secrets status                 # Auto: table if TTY, json otherwise

Book References

  • Search: pdf-brain search "output format table json" --fts --expand 2000
  • Search: pdf-brain search "isatty terminal detect" --fts --expand 2000

Priority

P1 - Better UX for both humans and agents

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions