Skip to content

feat: add --json flag to find and resolve commands#351

Merged
karthiknadig merged 1 commit intomainfrom
feature/issue-87
Feb 24, 2026
Merged

feat: add --json flag to find and resolve commands#351
karthiknadig merged 1 commit intomainfrom
feature/issue-87

Conversation

@karthiknadig
Copy link
Member

Adds a --json / -j flag to the find and resolve CLI commands for simple one-shot JSON output without needing the JSONRPC server.

  • pet find --json outputs { "managers": [...], "environments": [...] }
  • pet resolve --json <exe> outputs the resolved PythonEnvironment object (or null)
  • All other flags (--list, --verbose, --report-missing, etc.) continue to work as before
  • JSON serialization uses camelCase field naming consistent with the JSONRPC API
  • Summary/timing output is suppressed in JSON mode to keep stdout clean

Fixes #87

@karthiknadig karthiknadig requested a review from Copilot February 23, 2026 19:34
@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 58.3%
Base Branch Coverage 58.7%
Delta -.4% ❌

Coverage decreased. Please add tests for new code.

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Performance Report (Linux) ➖

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 79ms 699ms 76ms 3ms 0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 54.58%
Base Branch Coverage 54.95%
Delta -0.37% ❌

Coverage decreased. Please add tests for new code.

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Performance Report (Windows) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 9ms 12ms 10ms -1ms -10%
Full Refresh 149ms 6621ms 199ms -50ms -25.1%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

Copy link

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

This PR adds JSON output support to the find and resolve CLI commands via a new --json / -j flag, enabling simple one-shot usage without requiring the JSONRPC server. The implementation reuses existing infrastructure (the collect reporter for gathering results) and maintains consistency with the JSONRPC API's camelCase field naming.

Changes:

  • Added --json flag to both find and resolve CLI commands for structured JSON output
  • Implemented find_envs_json function that collects environments/managers and outputs them as JSON
  • Modified resolve_report_stdio to output JSON when the flag is set, including null for missing environments
  • Suppressed timing/summary output in JSON mode to keep stdout clean (logs still go to stderr)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/pet/src/main.rs Added json: bool field to Find and Resolve command structs and passed it to the handler functions
crates/pet/src/lib.rs Implemented JSON output logic: added find_envs_json function, modified resolve_report_stdio to support JSON, and imported necessary modules

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 83ms 730ms 55ms 28ms
Full Refresh 161ms 37675ms 114ms 47ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@karthiknadig karthiknadig merged commit 1a405f5 into main Feb 24, 2026
34 checks passed
@karthiknadig karthiknadig deleted the feature/issue-87 branch February 24, 2026 00:21
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.

Feature request: JSON output for $ pet find

3 participants