Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zig fmt: Add test mode which does not modify files #1555

Closed
xtian opened this Issue Sep 18, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@xtian
Copy link
Contributor

xtian commented Sep 18, 2018

zig fmt should have a flag which causes the command to not modify the files in place and instead simply output which files are incorrectly formatted and exit with a non-zero return code.

If this flag is not provided, zig fmt should not produce any output when parsing and formatting complete successfully.

This is standard behavior in all the formatters that I have experience with and is needed to check formatting in a CI or test context:

  • elm-format --validate
  • mix format --check-formatted
  • prettier --list-different
  • rustfmt --check

Happy to work on a PR for these changes if you think they’re a good idea! :)

@andrewrk andrewrk added this to the 0.4.0 milestone Sep 18, 2018

@andrewrk

This comment has been minimized.

Copy link
Member

andrewrk commented Sep 18, 2018

Makes sense. I think the implementation should be straightforward since we already detect changes and output which files end up being changed, so to implement this new mode shouldn't have to solve any new problems.

@binary132

This comment has been minimized.

Copy link

binary132 commented Sep 20, 2018

fwiw, the Go formatting tool defaults to output to stdout, and only edits files in-place if asked to.

@andrewrk

This comment has been minimized.

Copy link
Member

andrewrk commented Sep 21, 2018

zig fmt --stdin can be used to operate on stdin/stdout. By default there can be any number of positional arguments, and if any of them are directories then they are scanned recursively.

@andrewrk andrewrk closed this in 0c3bd0c Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.