laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.

Home Page:https://laravel.com/docs/pint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for formatter mode

bilogic opened this issue · comments

Hi,

All specified commands are expected to read in unformatted code on their stdin and print the formatted code to their stdout.
In all cases, if any text is printed to stderr, the error will be relayed to the "Custom Format" output panel.
If text is printed to stdout, error or no error, the file will be overwritten with the printed text.
If there is no content written to stdout, error or no error, the formatting of the file will be skipped.

I quoted the above from https://github.com/Vehmloewff/custom-format

  1. Read from STDIN
  2. If formatted successfully, print formatted file to STDOUT and nothing to STDERR
  3. If unable to format, print nothing to STDOUT, error/exception to STDERR and return non-zero

Can pint support an extra mode like this?

Thank you.

Thanks. Right now we have no plans for this, sorry.

What about a PR?

I also needed this function, but faked it with a script.
Maybe it's useful for someone:

file="$(mktemp --tmpdir=/dev/shm)"
cat - >"$file"
vendor/bin/pint --quiet "$file"
cat "$file"
rm "$file"

I have been using Zed editor and to make Pint work as a formatter I created the script: https://gist.github.com/gabrielbidula/4b8f84a02dafd242b0e1cf1d682fcaac