Closed ClementWalter closed 8 months ago
we do the same as rustfmt - which outputs the diff as well. why do you need the binary to return the formatted string? what is the usecase?
why do you need the binary to return the formatted string? what is the usecase?
@ClementWalter described his use case here: https://github.com/software-mansion/scarb/issues/700#issue-1910789861
As answered there - this does not actually require updates here if you want to use scarb fmt. You can feel free to use the direct binary here and add this feature to it - it would be basically the same work.
Feature Request
Describe the Feature Request
Currently, the
cairo format
can either overwrite the content, or output aFileDif
. The feature request is to output only the result, not the diff.Describe Preferred Solution
Add a flag
--emit stdout
like inrust fmt
Describe Alternatives
make
--check
returns the result and not the diffRelated Code
https://github.com/starkware-libs/cairo/blob/2e8142b67a4312c830aea1bb9e34631bf0e39a5d/crates/cairo-lang-formatter/src/cairo_formatter.rs#L209C9-L209C21
Additional Context
it's actually quite odd to have a
format_to_string
function that doesn't return a plain string but a FileDiff. The docstring actually seems to say that the returned result is the formatted output and not the diff neither. So maybe better just to return the output. Is anyone using the FileDiff? If not, the easiest would just be to update the current --check to return the formatted result.