dprint / dprint

Pluggable and configurable code formatting platform written in Rust.

Home Page:https://dprint.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[cli] accept a list of files from stdin

bradzacher opened this issue · comments

Sometimes it's useful to generate a list of files using some other tool and then pipe that file around.
Right now it's a bit cumbersome to do this with dprint because you have to go via xargs eg

$ generate_files | xargs dprint fmt --

There are certain issues with using dprint eg if you have filenames with spaces you need to change the delimiter config - which isn't portable across macos and linux (linux supports -d '\n' but macos does not).

It'd be great if we could do something like

$ generate_files | dprint fmt --stdin_files

So that dprint would treat stdin as a list of newline-separated paths to format.

Seems good to add. Yeah, another issue with arguments is they have a limit (on Windows it's 8191 chars).

Similarly it also might be nice to support a pattern file ego dprint fmt --pattern_file /some/file.txt in the same format as the above.

Sometimes scripts generate things on-the-fly and pipe it around, other times there is an file on disk - so an arg to say "read the list from here" would just save having to do cat /some/file.txt | dprint fmt --stdin_files and allow some things to be even more portable.