feat: Print formatted file names in mix format --verbose#15119
feat: Print formatted file names in mix format --verbose#15119josevalim merged 2 commits intoelixir-lang:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds informative output to mix format that displays which files were actually formatted, addressing the current silent behavior that provides no feedback about what changed. The feature follows Mix's established convention of using * verb path format for action messages.
Changes:
- Adds formatted file output using
* formatting pathformat with ANSI coloring - Introduces
--quietflag to restore previous silent behavior - Refactors internal tracking to distinguish between formatted and unchanged files
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/mix/lib/mix/tasks/format.ex | Core implementation: adds --quiet flag, refactors write_or_print to return formatting status, updates collect_status and check! to track and print formatted files |
| lib/mix/test/mix/tasks/format_test.exs | Adds three tests verifying formatted file output, --quiet flag suppression, and --dry-run suppression |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| refute_received {:mix_shell, :info, ["* formatting a.ex"]} | ||
| end) | ||
| end | ||
|
|
There was a problem hiding this comment.
Missing test coverage for --check-formatted flag interaction with the new formatting output feature. While the implementation correctly doesn't print formatting messages when --check-formatted is used (since it doesn't actually format files), this behavior should be explicitly tested to prevent regressions. Consider adding a test similar to the --dry-run and --quiet tests that verifies no formatting messages are printed when using --check-formatted.
| test "does not print formatted file names with --check-formatted", context do | |
| in_tmp(context.test, fn -> | |
| File.write!("a.ex", """ | |
| foo bar | |
| """) | |
| Mix.Tasks.Format.run(["a.ex, "--check-formatted"]) | |
| refute_received {:mix_shell, :info, ["* formatting a.ex"]} | |
| end) | |
| end |
|
This behaviour needs to be opt-in. We can have a --verbose mode. |
:( ok |
bb0ff8d to
168cc37
Compare
|
@josevalim updated |
168cc37 to
a459269
Compare
|
💚 💙 💜 💛 ❤️ |
|
😘 |
mix formatis completely silent on success right now, so you have no idea which files it actually changed. This is also useful for LLMs reading the output ofmix formatto know what was touched. This adds a--verboseflag that prints files as they're formatted, using the same* verb pathconvention as the rest of mix:Already-formatted files produce no output. Default behavior (silent) is unchanged.