Repository navigation
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 9702ab7. Configure here.
| .is_some_and(|value| value == "json") | ||
| || arg | ||
| .strip_prefix("-o") | ||
| .is_some_and(|value| !value.is_empty() && value == "json") |
There was a problem hiding this comment.
Equals short output flag ignored
Low Severity
requested_output_format recognizes -ojson and --output=json but not clap's valid short equals form -o=json. Parse failures using that flag still go through clap's plain-text stderr path instead of the JSON error object.
Reviewed by Cursor Bugbot for commit 9702ab7. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Problem
Cli::parse()exited before the application error formatter ran. As a result, malformed commands passed with--output jsonproduced plain text on stderr instead of the documented machine-readable JSON response.Approach
The entrypoint now uses
Cli::try_parse_fromand detects the requested output format from the raw arguments. Parse failures use the existing JSON error shape when appropriate, while help/version requests and table-mode failures retain standard Clap rendering.Tests
cargo +1.91.1 fmt --checkcargo +1.91.1 test --locked --test cli_integration— 54 passedcargo +1.91.1 clippy --locked --all-targets -- -D warningsgit diff --checkRisk
Low. The change is limited to initial argument parsing and preserves exit code 2 for invalid CLI input. Help and version output continue to use Clap's native behavior.
Fixes #99
Note
Low Risk
Scope is limited to startup argument parsing and error formatting; help, version, table-mode errors, and exit codes stay aligned with Clap.
Overview
Clap parse/validation failures now honor
--output jsoninstead of always printing plain-text errors to stderr before the app runs.The entrypoint switches from
Cli::parse()toCli::try_parse_from, with a smallrequested_output_formatscan of rawargs_os(including-ojson,--output=json, and flags after invalid commands). When JSON was requested, parse errors print a single{"error": "..."}object on stdout with Clap’s exit code (typically 2) and empty stderr; help/version and default table mode still use Clap’s normal rendering.Integration tests cover unknown commands, flag ordering, short
-ojsonvalidation errors, unchanged help with--output json, and preserved table-mode stderr behavior.Reviewed by Cursor Bugbot for commit 9702ab7. Bugbot is set up for automated code reviews on this repo. Configure here.