@@ -77,6 +77,8 @@ defmodule Mix.Tasks.Format do
7777
7878 * `--dry-run` - does not save files after formatting.
7979
80+ * `--verbose` - prints the names of files that were formatted.
81+
8082 * `--dot-formatter` - path to the file with formatter configuration.
8183 Defaults to `.formatter.exs` if one is available. See the
8284 "Formatting options" section above for more information.
@@ -199,6 +201,7 @@ defmodule Mix.Tasks.Format do
199201 no_exit: :boolean ,
200202 dot_formatter: :string ,
201203 dry_run: :boolean ,
204+ verbose: :boolean ,
202205 stdin_filename: :string ,
203206 force: :boolean ,
204207 migrate: :boolean
@@ -764,18 +767,27 @@ defmodule Mix.Tasks.Format do
764767 :ok
765768
766769 true ->
767- write_or_print ( file , input , output )
770+ write_or_print ( file , input , output , task_opts )
768771 end
769772 rescue
770773 exception ->
771774 { :exit , file , exception , __STACKTRACE__ }
772775 end
773776
774- defp write_or_print ( file , input , output ) do
777+ defp write_or_print ( file , input , output , task_opts ) do
775778 cond do
776- file == :stdin -> IO . write ( output )
777- input == output -> :ok
778- true -> File . write! ( file , output )
779+ file == :stdin ->
780+ IO . write ( output )
781+
782+ input == output ->
783+ :ok
784+
785+ true ->
786+ File . write! ( file , output )
787+
788+ if task_opts [ :verbose ] do
789+ Mix . shell ( ) . info ( [ :green , "* formatting " , :reset , Path . relative_to_cwd ( file ) ] )
790+ end
779791 end
780792
781793 :ok
0 commit comments