[Feature Request] Accept stdin or files with different extensions
jtrv opened this issue · 3 comments
Why?
-
Case 1: I use a program to edit browser inputs with my text editor. It saves the active input as a .txt file and opens it in the editor, then fills the input with the text once the editor exits. I cannot use prettierd to format the text in these files. Prettierd returns "no files specified" when passed a .txt file.
-
Case 2: There is currently no way for me to use prettierd to only format a certain selection of code as with kakoune's
format-selection
command. In it's current form prettierd only takes a file as input and output.
How?
-
Option 1: Accept text from stdin using
-f
or--format
to designate the format:cat file.txt | prettierd --format html -
-
Option 2: Accept files with any extension using
-f
or--format
to designate the format:prettierd --format html file.txt
Option 1 would be the most optimal since it would solve both of the above cases.
I'm confused, prettierd only supports reading from stdin. It does not support reading the contents directly from a file. It takes the filename just to resolve configuration (including which parser to use). You don't need to give it a path to a file that actually exists. For example:
$ prettierd ${PWD}/index.html <<<"<h1> hi</h1>"
Should work, regardless of whether index.html exists or not.
Sorry it looks like I totally misinterpreted what was going on, I'll close out this issue.
@JacobTravers no problem, feel free to reach out if you run into any other issues.