@@ -109,6 +109,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
109109
110110 let Command :: Format {
111111 do_print_to_stdout,
112+ use_verbose_output,
112113 do_check_formatted_only,
113114 use_spaces,
114115 indent_size,
@@ -187,12 +188,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
187188
188189 let total_files = input_gdscript_files. len ( ) ;
189190
190- eprint ! (
191- "Formatting {} file{}..." ,
192- total_files,
193- if total_files == 1 { "" } else { "s" }
194- ) ;
195- let _ = io:: stdout ( ) . flush ( ) ;
191+ if !use_verbose_output {
192+ eprint ! (
193+ "Formatting {} file{}..." ,
194+ total_files,
195+ if total_files == 1 { "" } else { "s" }
196+ ) ;
197+ let _ = io:: stdout ( ) . flush ( ) ;
198+ }
196199
197200 let mut sorted_outputs: Vec < Result < FormatterOutput , String > > =
198201 format_files_parallel ( & input_gdscript_files, & config, config_overrides) ;
@@ -206,6 +209,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
206209 match output {
207210 Ok ( output) => {
208211 if do_check_formatted_only {
212+ if use_verbose_output {
213+ eprintln ! (
214+ "Checking {}... {}" ,
215+ output. file_path. display( ) ,
216+ if output. is_formatted {
217+ "OK"
218+ } else {
219+ "needs formatting"
220+ }
221+ ) ;
222+ }
209223 if !output. is_formatted {
210224 all_formatted = false ;
211225 unformatted_files. push ( output. file_path ) ;
@@ -217,6 +231,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
217231 println ! ( "#--file:{}" , output. file_path. display( ) ) ;
218232 }
219233 print ! ( "{}" , output. formatted_content) ;
234+ if use_verbose_output {
235+ eprintln ! (
236+ "Formatting {}... {}" ,
237+ output. file_path. display( ) ,
238+ if output. is_formatted {
239+ "already formatted"
240+ } else {
241+ "done"
242+ }
243+ ) ;
244+ }
220245 } else if !output. is_formatted {
221246 fs:: write ( & output. file_path , output. formatted_content ) . map_err ( |error| {
222247 format ! (
@@ -226,6 +251,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
226251 )
227252 } ) ?;
228253 modified_file_count += 1 ;
254+ if use_verbose_output {
255+ eprintln ! ( "Formatting {}... done" , output. file_path. display( ) ) ;
256+ }
257+ } else if use_verbose_output {
258+ eprintln ! (
259+ "Formatting {}... already formatted" ,
260+ output. file_path. display( )
261+ ) ;
229262 }
230263 }
231264 Err ( error_msg) => {
@@ -235,35 +268,55 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
235268 }
236269
237270 if do_check_formatted_only {
238- terminal_clear_line ( ) ;
271+ if !use_verbose_output {
272+ terminal_clear_line ( ) ;
273+ }
274+ let summary_prefix = if use_verbose_output { "" } else { "\r " } ;
239275 if all_formatted {
240- eprintln ! ( "\r All {} file(s) are formatted" , total_files) ;
276+ eprintln ! (
277+ "{}All {} file(s) are formatted" ,
278+ summary_prefix, total_files
279+ ) ;
241280 } else {
242- eprintln ! ( "\r Some files are not formatted" ) ;
281+ eprintln ! ( "{}Some files are not formatted" , summary_prefix ) ;
243282 for file_path in unformatted_files {
244283 eprintln ! ( "{}" , file_path. display( ) ) ;
245284 }
246285 std:: process:: exit ( ERROR_CODE_NOT_FORMATTED ) ;
247286 }
248287 } else if !do_print_to_stdout {
249- terminal_clear_line ( ) ;
288+ if !use_verbose_output {
289+ terminal_clear_line ( ) ;
290+ }
291+ let summary_prefix = if use_verbose_output { "" } else { "\r " } ;
250292 if total_files == 1 {
251293 if modified_file_count > 0 {
252- eprintln ! ( "\r Formatted {}" , input_gdscript_files[ 0 ] . display( ) ) ;
294+ eprintln ! (
295+ "{}Formatted {}" ,
296+ summary_prefix,
297+ input_gdscript_files[ 0 ] . display( )
298+ ) ;
253299 } else {
254- eprintln ! ( "\r Already formatted: {}" , input_gdscript_files[ 0 ] . display( ) ) ;
300+ eprintln ! (
301+ "{}Already formatted: {}" ,
302+ summary_prefix,
303+ input_gdscript_files[ 0 ] . display( )
304+ ) ;
255305 }
256306 } else {
257307 let already_formatted_count = total_files - modified_file_count;
258308 if modified_file_count > 0 && already_formatted_count > 0 {
259309 eprintln ! (
260- "\r Formatted {} files, {} already formatted" ,
261- modified_file_count, already_formatted_count
310+ "{}Formatted {} files, {} already formatted" ,
311+ summary_prefix , modified_file_count, already_formatted_count
262312 ) ;
263313 } else if modified_file_count > 0 {
264- eprintln ! ( "\r Formatted {} files" , modified_file_count) ;
314+ eprintln ! ( "{}Formatted {} files" , summary_prefix , modified_file_count) ;
265315 } else {
266- eprintln ! ( "\r All {} files already formatted" , total_files) ;
316+ eprintln ! (
317+ "{}All {} files already formatted" ,
318+ summary_prefix, total_files
319+ ) ;
267320 }
268321 }
269322 }
0 commit comments