kkinnear / zprint

Executables, uberjar, and library to beautifully format Clojure and Clojurescript source code and s-expressions.
MIT License
556 stars 48 forks source link

Is it possible to operate on a stream from stdin? #332

Open blak3mill3r opened 2 months ago

blak3mill3r commented 2 months ago

I couldn't find a way to do this with zprint, I suspect it isn't supported.

I wonder what it would take to add that. I think it would be useful.

I tried this, hoping it would work:

tail -f something.edn | zprint
kkinnear commented 2 months ago

Sorry for the delay in replying. Been a busy week around here!

What an interesting request. I have used tail -f for years in a different context than zprint, but certainly never imagined piping the output of tail -f to another program! I presume that you want what shows up on stdout to be the formatted file, and if more stuff ends up in the file, that additional stuff would also show up (formatted of course) on stdout?

Presently, zprint reads the entire file into memory before formatting it, so it won't do anything until the input file is closed.

I'm interested in your particular use case. It would probably be quite a bit of work to alter zprint to format an input file in fragments instead of processing the whole file. Before I would tackle that as a new feature, I'd like to better understand what you are trying to accomplish. I can imagine some use cases, but I've found that people's actual use cases rarely match up to my imagination. Thanks!