Add --json output flag for batch query results
- Lingua principale
- Python
- Stelle
- 3.3k
- Fork
- 95
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Problem
`litecli` already supports `--csv` and `--table` for batch output (used with `-e` and stdin queries), but it has no equivalent `--json` flag. The underlying `cli_helpers` library already ships a `json_output_adapter.py`, so the formatter is available — only the CLI flag is missing.
### Solution
Add a `--json` flag parallel to the existing `--csv` and `-t`/`--table` options on the root `cli` command. In the `-e` and stdin branches of `litecli/main.py`, set `litecli.formatter.format_name = "json"` next to the existing `format_name = "csv"` / `"tsv"` assignments. The change should be ~5 lines.
A `table_format = "json"` entry could also be accepted in `~/.config/litecli/config`, mirroring the existing `table_format = "csv"` knob.
### Use case
Scripting and CI pipelines:
litecli mydb.sqlite -e "select id, name from users" --json | jq '.[] | select(.name | startswith("a"))'
…instead of having to pipe `--csv` through `jq -r '@csv'` round-tripping.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da litecli/main.py ed esamina le opzioni della CLI root e la gestione esistente di --csv e --table nei rami -e e stdin. Verifica come viene assegnato litecli.formatter.format_name, quindi controlla che --json compaia nell’help e produca JSON per entrambi gli entry point batch usando la query di esempio; la voce di configurazione opzionale dovrebbe rispecchiare l’impostazione table_format esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, sqlite
- Ambito
- cli
- Tipo di issue
- Funzionalità
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 84/100