Output formatting (table/csv/json) #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Plan 9: Output formatting
Goal
Parse the
Columns:andSeparator:headers already present inBasicResultand offer structured output modes: raw (current default), table, CSV, JSON.
Where the data is
BasicResultalready has:Separatordefaults to space per the spec;\tis the tab variant.Design
New flag
Add
--formattomain.go:New function in
cmd/joker/Reads
result.Status()for theColumns/Separatorfields, reads the body,and renders accordingly.
raw: currentio.Copybehavior — zero changetable:text/tabwriterwith column headers fromColumnscsv:encoding/csv, columns fromColumnsjson: one JSON object per line, keys fromColumnsWhat "Columns" looks like
The
Columnsheader is a comma-separated list of column names, e.g.:Rows in the body are space- or tab-separated (per
Separator).Caveats
query-profile,query-whoisreturn key:value lines). For those,
Columnsis empty; fall back toraw.dns-zone-getreturns raw zone file text. Alwaysraw.result.(*BasicResult)type assertion is needed to accessColumns;the
Resultinterface only exposesio.Reader. Cast defensively.Implementation order
--formatflag (no-op initially, always raw)table(most useful)csvjsonAI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex