Skip to content
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

Request: flag(s) to take input from stdin and send output to stdout, rather than in-place editing #118

Closed
AndydeCleyre opened this issue Oct 25, 2024 · 4 comments

Comments

@AndydeCleyre
Copy link
Contributor

AndydeCleyre commented Oct 25, 2024

This came up for me specifically trying to integrate ssort into the Zed editor, which expects any provided external formatter to output the new content to stdout, and take input from stdin.

@AndydeCleyre AndydeCleyre changed the title Request: flag to send output to stdout, rather than in-place editing Request: flag(s) to take input from stdin and send output to stdout, rather than in-place editing Oct 25, 2024
@bwhmather
Copy link
Owner

That sounds very reasonable. If you're up for writing a PR then I would be enthusiastic to help get it merged and released. I think it should just be a matter of a few small tweaks to _main.py.

@AndydeCleyre
Copy link
Contributor Author

Thanks, I'll submit something!

I think it'll be sufficient to have a mode that reads stdin, and in that case writes stdout (no need for a separate stdout option).

Which would you prefer of

  1. --stdin
  2. A single dash - where the file args usually go
  3. Detect when content is being piped
  4. Something else

?

@bwhmather
Copy link
Owner

I had assumed --stdout but I think you are right that there's no need. Looks like isort and black both go with option 2 so might as well be consistent with that.

@AndydeCleyre
Copy link
Contributor Author

Completed in 0.14.0 with #119 !

For anyone finding this, passing - as a file arg now means read stdin and send formatted result to stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants