Add --json output flag for batch query results
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
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.
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.
- Lingua principale
- Python
- Stelle
- 3.3k
- Fork
- 95
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dbcli/litecli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di dbcli/litecli
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100