Skip to content

feat(http): add ?format=text|csv|tsv output option - #14

Merged
0xeb merged 1 commit into
mainfrom
feat/http-output-format
Jun 23, 2026
Merged

0xeb merged 1 commit into
mainfrom
feat/http-output-format

Conversation

@0xeb

@0xeb 0xeb commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Adds an opt-in format query-string parameter to POST /query. JSON stays the default and canonical machine format — this is for direct terminal/curl/unix-pipe use, not for agents (agents should consume the JSON).

format Content-Type
(default) / json application/json
text text/plain (ASCII table)
csv text/csv (RFC 4180)
tsv text/tab-separated-values

Unknown/absent format falls back to JSON. /help and the README document it; the README's stale flat Response Format example is corrected to the real script envelope.

Depends on

0xeb/libxsql#4 (adds script_result_to_csv/tsv). For sibling-checkout builds it's already available; for FetchContent (GIT_TAG main) builds, merge the libxsql PR first.

Tested (live, against /usr/bin/cpio)

  • ?format=text|csv|tsv → correct body + Content-Type.
  • Default (no param) → unchanged JSON envelope.
  • CSV quoting verified: 'a,b' → "a,b", 'he said "hi"' → "he said ""hi""", NULL → empty field.
  • /help lists the option.

The /query endpoint defaults to JSON (canonical machine format); add an opt-in
query-string 'format' for direct terminal/curl/unix-pipe use:
  text -> text/plain (ASCII table, via script_result_to_text)
  csv  -> text/csv (RFC 4180)
  tsv  -> text/tab-separated-values
Unknown/absent format falls back to JSON. /help and README document it, and the
README Response Format example is corrected to the real script envelope.

Depends on libxsql script_result_to_csv/tsv (0xeb/libxsql#4).
@0xeb
0xeb merged commit d954945 into main Jun 23, 2026
2 of 8 checks passed
@0xeb
0xeb deleted the feat/http-output-format branch June 23, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant