Closed ii8 closed 10 months ago
smlfmt
does accept stdin/stdout:
cat a.sml | smlfmt > b.sml
# or, alternatively:
smlfmt < a.sml > b.sml
One nice thing about the in-place-by-default behavior is that it's consistent between .sml
and .mlb
input. And, in-place updates seem like they would be the common case for a tool like smlfmt
. (This is certainly the case for me, but not sure about other people.)
Honestly I don't have a super strong preference either way, but I'm a bit wary of changing things.
Oh, indeed smlfmt < a.sml > b.sml
works but using smlfmt > b.sml
and pasting doesn't, that's why I thought it doesn't work in general.
It just seemed a bit strange to me, but if you don't think it should be changed this issue can be closed.
Okay sounds good! For now, I think I'd prefer not to change it, just in case someone is relying on the existing interface.
I'll keep in it mind though; if we need to make a backwards-incompatible change in the future anyway, then perhaps this can be changed then too.
Currently there seems to be no way to write the output to a different file. For example:
will produce an invalid b.sml that doesn't compile. And further the default behavior without passing arguments is to overwrite the given file after asking for interactive confirmation.
The typical behavior for command line text transformation tools like this is to use
stdin
andstdout
by default, not ask for confirmation and not overwrite by default. Here are some examples:smlfmt is at odds with a convention that, in my opinion, is quite reasonable.