dbcli / dbcli/litecli

Add --json output flag for batch query results

Đang mở Phù hợp với người mới
#263 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
3.3k
Fork
95
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start in litecli/main.py and inspect the root cli options plus the existing --csv and --table handling in the -e and stdin branches. Confirm how litecli.formatter.format_name is assigned, then verify that --json appears in help and produces JSON for both batch entry points using the example query; the optional config entry should mirror the existing table_format setting.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python, sqlite
Lĩnh vực
cli
Loại issue
Tính năng
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
84/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.