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

Support STDIN/STDOUT #37

Closed
alok opened this issue Apr 30, 2018 · 11 comments
Closed

Support STDIN/STDOUT #37

alok opened this issue Apr 30, 2018 · 11 comments

Comments

@alok
Copy link

alok commented Apr 30, 2018

If there was a flag like --stdout to output the changed text to STDOUT, that would be nice.

Being able to read from STDIN would make it perfect for autoformatters like neoformat.

@asottile
Copy link
Owner

I believe you're looking for --print-only?

@alok
Copy link
Author

alok commented Apr 30, 2018

My bad. Does this support reading STDIN as well (AFK, so I can't check right now)?

@asottile
Copy link
Owner

reorder-python-imports /dev/stdin --print-only should work:

$ echo -e 'import os\nimport pre_commit\nimport sys' | reorder-python-imports /dev/stdin --print-only
==> /dev/stdin <==
import os
import sys

import pre_commit

@asottile
Copy link
Owner

(note that the ==> /dev/stdin <== output goes to stderr)

@asottile asottile closed this as completed Jul 1, 2018
@asottile
Copy link
Owner

asottile commented Jul 1, 2018

closing: if --print-only doesn't satisfy your usecase please provide additional context and I'll reopen :)

@alok
Copy link
Author

alok commented Jul 1, 2018

Sorry, forgot about this. It needs to output specifically to STDOUT rather than STDERR since most editor formatter plugins only read STDOUT. Plus, it's not really an error as such, so it shouldn't be redirected there.

@asottile
Copy link
Owner

asottile commented Jul 1, 2018

it does, you haven't tried it have you :P

@alok
Copy link
Author

alok commented Jul 1, 2018

You're right, I didn't. I misread the sentence "(note that the ==> /dev/stdin <== output goes to stderr)". I thought you meant all of it was redirected to STDERR rather than just that literal line. My bad.

@alok
Copy link
Author

alok commented Jul 1, 2018

On the other hand, I don't think Windows supports /dev/stdin. I don't use Windows, but I'd expect other people do.

@asottile
Copy link
Owner

asottile commented Jul 1, 2018

If someone on windows wants the feature then we'll talk -- as it is it hasn't been an ask so far and if I'm not going to use it and you're not going to use it there's no point in complicating this tool

@pmiddend
Copy link

I'm trying to implement emacs support for this fine tool. This would be a little easier if --print-only always printed the result, whether there was a reordering or not. Is that possible?

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

3 participants