tox-dev / pyproject-fmt

MIT License
167 stars 27 forks source link

Allow for reading from stdin #238

Closed fniessink closed 1 month ago

fniessink commented 1 month ago

I'd like to configure pyproject-fmt as formatter in Zed. Formatters in Zed need to be able to read from stdin and write to stdout. It seems pyproject-fmt can do the latter, but not the former.

Is this something you would consider adding? I can provide a PR if you'd like.

I was thinking of adding this as flag under run mode:

run mode:
   -s, --stdout          print the formatted TOML to the stdout (default: False)
   -i, --stdin           read the TOML to format from the stdin (default: False)
gaborbernat commented 1 month ago

PR welcome.

fniessink commented 1 month ago

PR opened (#239). I opted for using '-' to signify reading from stdin as it seemed a bit easier to implement: no need for extra flags in the CLI nor in the code.