@@ -11,6 +11,9 @@ mod progress;
1111mod utils;
1212
1313use crate :: cli:: Cli ;
14+ use crate :: config:: Config ;
15+ use crate :: display_node:: DisplayNode ;
16+ use crate :: node:: FileTime ;
1417use crate :: progress:: RuntimeErrors ;
1518use clap:: Parser ;
1619use dir_walker:: WalkData ;
@@ -298,32 +301,52 @@ fn main() {
298301 let print_errors = config. get_print_errors ( & options) ;
299302 print_any_errors ( print_errors, walk_data. errors ) ;
300303
301- if let Some ( root_node) = tree {
302- if config. get_output_json ( & options) {
303- OUTPUT_TYPE . with ( |wrapped| {
304- wrapped. replace ( output_format) ;
305- } ) ;
306- println ! ( "{}" , serde_json:: to_string( & root_node) . unwrap( ) ) ;
307- } else {
308- let idd = InitialDisplayData {
309- short_paths : !config. get_full_paths ( & options) ,
310- is_reversed : !config. get_reverse ( & options) ,
311- colors_on : is_colors,
312- by_filecount,
313- by_filetime,
314- is_screen_reader : config. get_screen_reader ( & options) ,
315- output_format,
316- bars_on_right : config. get_bars_on_right ( & options) ,
317- } ;
304+ print_output (
305+ config,
306+ options,
307+ tree,
308+ walk_data. by_filecount ,
309+ by_filetime,
310+ is_colors,
311+ terminal_width,
312+ )
313+ }
318314
319- draw_it (
320- idd,
321- config. get_no_bars ( & options) ,
322- terminal_width,
323- & root_node,
324- config. get_skip_total ( & options) ,
325- )
326- }
315+ fn print_output (
316+ config : Config ,
317+ options : Cli ,
318+ tree : DisplayNode ,
319+ by_filecount : bool ,
320+ by_filetime : Option < FileTime > ,
321+ is_colors : bool ,
322+ terminal_width : usize ,
323+ ) {
324+ let output_format = config. get_output_format ( & options) ;
325+
326+ if config. get_output_json ( & options) {
327+ OUTPUT_TYPE . with ( |wrapped| {
328+ wrapped. replace ( output_format) ;
329+ } ) ;
330+ println ! ( "{}" , serde_json:: to_string( & tree) . unwrap( ) ) ;
331+ } else {
332+ let idd = InitialDisplayData {
333+ short_paths : !config. get_full_paths ( & options) ,
334+ is_reversed : !config. get_reverse ( & options) ,
335+ colors_on : is_colors,
336+ by_filecount,
337+ by_filetime,
338+ is_screen_reader : config. get_screen_reader ( & options) ,
339+ output_format,
340+ bars_on_right : config. get_bars_on_right ( & options) ,
341+ } ;
342+
343+ draw_it (
344+ idd,
345+ config. get_no_bars ( & options) ,
346+ terminal_width,
347+ & tree,
348+ config. get_skip_total ( & options) ,
349+ )
327350 }
328351}
329352
0 commit comments