Skip to content

Add --json option to list CLI commands#399

Merged
lemon24 merged 7 commits intolemon24:masterfrom
puneetdixit200:add-json-cli-option
May 4, 2026
Merged

Add --json option to list CLI commands#399
lemon24 merged 7 commits intolemon24:masterfrom
puneetdixit200:add-json-cli-option

Conversation

@puneetdixit200
Copy link
Copy Markdown
Contributor

@puneetdixit200 puneetdixit200 commented May 1, 2026

Adds a --json flag to the list feeds and list entries CLI commands.

When used, output is emitted as JSON Lines (one JSON object per line), making it easier to use in scripts and pipelines.

Implementation details:

  • Uses _json_default for serialization (handles dataclasses and datetime)
  • Outputs JSON Lines (one object per line, not an array)
  • Keeps existing plain-text output unchanged

Tests:

  • Added tests for --json output
  • Updated tests to remove deprecated catch_exceptions argument from CliRunner

Example usage:

python -m reader list feeds --json
python -m reader list entries --json

Copilot AI review requested due to automatic review settings May 1, 2026 15:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a --json flag to the reader list feeds and reader list entries CLI commands to support JSON Lines output for scripting/pipelines, while keeping the existing plain-text output as the default.

Changes:

  • Add --json option to list feeds and list entries.
  • Serialize feed/entry objects to JSON (currently via _hash_utils._dataclass_dict and json.dumps()).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py
@puneetdixit200
Copy link
Copy Markdown
Contributor Author

puneetdixit200 commented May 1, 2026

@lemon24 Should I implement changes recommend by copilot?

Copy link
Copy Markdown
Owner

@lemon24 lemon24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments (some as replies to the Copilot ones).

Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
Comment thread src/reader/_cli.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.28%. Comparing base (54552cb) to head (a271775).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #399   +/-   ##
=======================================
  Coverage   94.27%   94.28%           
=======================================
  Files         103      103           
  Lines       13510    13529   +19     
  Branches      997      999    +2     
=======================================
+ Hits        12737    12756   +19     
  Misses        692      692           
  Partials       81       81           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@puneetdixit200 puneetdixit200 force-pushed the add-json-cli-option branch from 3bd40ee to d27c056 Compare May 1, 2026 23:13
@puneetdixit200 puneetdixit200 changed the title #394 done= added --json option to list commands for feed and entries Add --json option to list CLI commands May 1, 2026
Copy link
Copy Markdown
Owner

@lemon24 lemon24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, after this round of comments it should be good to go!

Comment thread src/reader/_cli.py

"""
def entries(reader, json_output):
"""List all the entries."""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per previous comment, this docstring should be left unchanged (no additions, no removals).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing the "Outputs one line per entry in the following format: ..." part, I'll fix it after merge.

Comment thread tests/test_cli.py
Comment thread tests/test_cli.py Outdated
Comment thread tests/test_cli.py Outdated
Comment thread src/reader/_cli.py
@lemon24 lemon24 merged commit 0947e10 into lemon24:master May 4, 2026
20 checks passed
@lemon24
Copy link
Copy Markdown
Owner

lemon24 commented May 4, 2026

@puneetdixit200, thank you for the PR!

lemon24 added a commit that referenced this pull request May 4, 2026
lemon24 added a commit that referenced this pull request May 4, 2026
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.

3 participants