@@ -11,7 +11,10 @@ mod progress;
1111mod utils;
1212
1313use crate :: cli:: Cli ;
14+ use crate :: node:: FileTime ;
15+ use crate :: config:: Config ;
1416use crate :: progress:: RuntimeErrors ;
17+ use crate :: display_node:: DisplayNode ;
1518use clap:: Parser ;
1619use dir_walker:: WalkData ;
1720use display:: InitialDisplayData ;
@@ -298,32 +301,37 @@ 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 ( config, options, tree, walk_data. by_filecount , by_filetime, is_colors, terminal_width)
305+ }
318306
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- }
307+ fn print_output ( config : Config , options : Cli , tree : DisplayNode , by_filecount : bool , by_filetime : Option < FileTime > , is_colors : bool , terminal_width : usize ) {
308+
309+ let output_format = config. get_output_format ( & options) ;
310+
311+ if config. get_output_json ( & options) {
312+ OUTPUT_TYPE . with ( |wrapped| {
313+ wrapped. replace ( output_format) ;
314+ } ) ;
315+ println ! ( "{}" , serde_json:: to_string( & tree) . unwrap( ) ) ;
316+ } else {
317+ let idd = InitialDisplayData {
318+ short_paths : !config. get_full_paths ( & options) ,
319+ is_reversed : !config. get_reverse ( & options) ,
320+ colors_on : is_colors,
321+ by_filecount,
322+ by_filetime,
323+ is_screen_reader : config. get_screen_reader ( & options) ,
324+ output_format,
325+ bars_on_right : config. get_bars_on_right ( & options) ,
326+ } ;
327+
328+ draw_it (
329+ idd,
330+ config. get_no_bars ( & options) ,
331+ terminal_width,
332+ & tree,
333+ config. get_skip_total ( & options) ,
334+ )
327335 }
328336}
329337
0 commit comments