From 75308588a2378bf38675c6555f316b2002aa335f Mon Sep 17 00:00:00 2001 From: "Victor M. Varela" Date: Fri, 20 Mar 2026 01:56:41 +0100 Subject: [PATCH] docs: add --json flag and Alpine APK install to README and man page Closes #76 --- README.md | 19 +++++++++++++++++++ docs/sql-pipe.1.scd | 17 +++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f63b6cf..6f8f686 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,15 @@ sudo rpm -i https://github.com/vmvarela/sql-pipe/releases/latest/download/sql-pi Replace `VERSION` with the release version (e.g. `0.2.0`) and `x86_64` with your architecture (`aarch64`). +**Alpine Linux (.apk package):** + +```sh +wget https://github.com/vmvarela/sql-pipe/releases/latest/download/sql-pipe_VERSION_x86_64.apk +sudo apk add --allow-untrusted sql-pipe_VERSION_x86_64.apk +``` + +Replace `VERSION` with the release version (e.g. `0.2.0`) and `x86_64` with your architecture (`aarch64`). + **Arch Linux (AUR):** install with your preferred AUR helper: ```sh @@ -138,6 +147,15 @@ $ cat data.tsv | sql-pipe --tsv 'SELECT * FROM t' $ cat data.tsv | sql-pipe --delimiter '\t' 'SELECT * FROM t' ``` +Output results as a JSON array of objects with `--json`: + +```sh +$ printf 'name,age\nAlice,30\nBob,25' | sql-pipe --json 'SELECT * FROM t' +[{"name":"Alice","age":30},{"name":"Bob","age":25}] +``` + +`--json` is mutually exclusive with `-d`/`--delimiter`, `--tsv`, and `-H`/`--header`. + Chain queries by piping back in — useful for two-pass aggregations: ```sh @@ -154,6 +172,7 @@ $ cat events.csv \ | `--tsv` | Alias for `--delimiter '\t'` | | `--no-type-inference` | Treat all columns as TEXT (skip auto-detection) | | `-H`, `--header` | Print column names as the first output row | +| `--json` | Output results as a JSON array of objects (mutually exclusive with `-d`, `--tsv`, `-H`) | | `-h`, `--help` | Show usage help and exit | | `-V`, `--version` | Print version and exit | diff --git a/docs/sql-pipe.1.scd b/docs/sql-pipe.1.scd index 66edd9b..a3143b4 100644 --- a/docs/sql-pipe.1.scd +++ b/docs/sql-pipe.1.scd @@ -9,7 +9,7 @@ SYNOPSIS DESCRIPTION sql-pipe reads CSV data from standard input, loads it into an in-memory SQLite database table named *t*, executes the provided SQL query, and prints the results - as CSV to standard output. + as CSV (or JSON when *--json* is used) to standard output. This tool is useful for quick data transformations, filtering, grouping, and aggregations on CSV files without manual SQL database setup. @@ -44,7 +44,13 @@ OPTIONS Print a header row with column names as the first line of output. Column names are taken from the SQL column alias or original name. The output remains valid CSV that can be piped back into sql-pipe. Header output is - off by default. + off by default. Cannot be combined with *--json*. + + *--json* + Output results as a JSON array of objects instead of CSV. Each row + becomes a JSON object with column names as keys and typed values (string, + number, or null). Mutually exclusive with *--delimiter*, *--tsv*, and + *--header*. *-h, --help* Print the help message and exit with code 0. @@ -89,6 +95,13 @@ EXAMPLES $ cat data.tsv | sql-pipe --tsv 'SELECT \* FROM t' + Output results as JSON: + + $ printf 'name,age\nAlice,30\nBob,25' | sql-pipe --json 'SELECT \* FROM t' + + Output:++ + [{"name":"Alice","age":30},{"name":"Bob","age":25}] + EXIT CODES *0* Success: query executed successfully and results were output.