-
Notifications
You must be signed in to change notification settings - Fork 170
Add stdin support with explicit opt-in flag #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Why is there so much more code than the original PR? |
* feat: add support for formatting code from stdin * Formatting --------- Co-authored-by: Taylor Otwell <[email protected]>
90ee57a
to
02096d4
Compare
Ha, yeah... I definitely over-engineered that. My bad. Started fresh with the original PR and just swapped the auto-detection for the flag check. Ready for review! |
@calebdw any feedback on this? 🙏 |
This is fine I suppose, there's many ways to go about this. It's also pretty standard to read from STDIN when Not saying we have to do all that, just food for thought. |
I like the idea of using stdin if |
If we're going with |
Sounds good! I'll update it to use |
@calebdw @taylorotwell Done! Using Re: exclusions - Stdin input is formatted regardless of exclusion patterns (like Zed editor example: {
"languages": {
"PHP": {
"formatter": {
"external": {
"command": "vendor/bin/pint",
"arguments": ["--stdin-filename", "{buffer_path}"]
}
}
}
}
} |
123b3fa
to
efff729
Compare
- Replace --stdin flag with Unix-standard dash (-) for stdin input - Add --stdin-filename option for editor integration and context - Support both 'pint -' and 'pint --stdin-filename' patterns - Add comprehensive tests for stdin formatting scenarios
efff729
to
e9e318d
Compare
Hey team,
This brings back stdin support from #390, but with an explicit
--stdin
flag to avoid thebreaking changes that caused the revert.
The Problem
The original implementation would automatically read from stdin if it was available, which
broke VSCode and PHPStorm extensions since they were inadvertently leaving stdin open when
calling pint.
What Changed
Now you need to explicitly pass
--stdin
to enable stdin mode. This means existing toolswon't break, and editors can opt-in when they're ready.
You can also pass a file path along with
--stdin
for better config resolution:In stdin mode, pint outputs only the formatted code to stdout (no summary), which is what
editors expect.
Testing
Added comprehensive tests covering:
All existing tests still pass.
Zed Integration Example
Fixes the issues raised in #402 and implements the solution suggested in #390.