Add JSON output method for doctor#22448
Conversation
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Great idea but I think this needs a lot of work before we can merge. We need to actually provide structured output from all diagnostics rather than relying on regexes.
There was a problem hiding this comment.
Pull request overview
This PR adds JSON output support to brew doctor, making diagnostic results easier for scripts and tools to consume.
Changes:
- Adds a
--jsonswitch tobrew doctor. - Builds and prints a JSON object containing a support tier and findings.
- Adds the generated Sorbet RBI predicate and a basic command spec.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
Library/Homebrew/cmd/doctor.rb |
Adds JSON output generation for doctor diagnostics. |
Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/doctor.rbi |
Adds the json? argument predicate. |
Library/Homebrew/test/cmd/doctor_spec.rb |
Adds a basic spec for brew doctor --json. |
Files not reviewed (1)
- Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/doctor.rbi: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Fair enough, I'd suggest a structure like this:
That we can then turn into a string or json object in the output. |
|
@SMillerDev yeh something like that sounds good. Also may want to have things like: affected formulae/casks, relevant URL(s). |
|
Adjusted to include that |
|
@SMillerDev looks good except we need to return the structured data from diagnostics rather than using regex on their string output. |
|
Yeah, fully planning to do that. Just wanted to work out a structure here before I get on reshaping all audit check output 😅 |
81d5b7e to
3bbaf15
Compare
|
JSON output: {
"tier": 1,
"findings": [
{
"title": "Deprecated or disabled formulae",
"issue": "Some installed formulae are deprecated or disabled.",
"tier": 1,
"affects": [
"php@7.2",
"mysql@8.0"
],
"links": [],
"remediation": {
"commands": [],
"text": "You should find replacements for the following formulae:\nmysql@8.0\n php@7.2\n"
}
}
]
} |
3bbaf15 to
bb17f35
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks, this is looking good! Will take another look when 🟢 and comments addressed. Happy to discuss more before addressing.
e94087a to
2324ef7
Compare
1c6fc38 to
df190b2
Compare
b2f7195 to
a816ce5
Compare
a816ce5 to
800b5e2
Compare
Add an option to output the
brew doctorresults in easily parseable JSON output.brew lgtm(style, typechecking and tests) with your changes locally?