-
Notifications
You must be signed in to change notification settings - Fork 72
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 and stdout as input file and output file in command line? #494
Comments
Thanks for clarifying. I think an alternative would be the following:
#!/usr/local/bin/Rscript
con <- file("stdin")
out <- styler::style_text(readLines(con))
close(con)
out
echo "1+1" | styler.r
1 + 1 or cat r-script.R | styler.r if your code is in a script. |
How about adding stdin argument into styler. It is possible to do that in formatR. cat test.R | R --slave --no-restore --no-save -e "formatR::tidy_source('stdin')" |
For vim plugin support, the formatter tool should be a single excutable or a one liner code. |
Ok. So we have support for styler in ale, just added a few days ago, which is a VIM Plug-in: dense-analysis/ale#2401 (comment). Maybe this is what you are looking for? |
I also pushed a commit for styler support in neoformat (another popular vim plugin) a few days ago, but it is not perfect. I need readr for styler to make it work. |
But why not using the approach I used above with readLines(file(„stdin“)) instead of the approach with readr? |
I forget to close file, and got some error in the first attempt. It works fine now. Thank you @lorenzwalthert BTW, the performance of styler is a little slow. Even if the file is well formatted. styler::style_text (for 20 lines of R code)
black formatter of python (for a large file)
|
will it be possible?
my solution: (require readr package)
The text was updated successfully, but these errors were encountered: