@@ -7,7 +7,7 @@ use crate::{
77 bytes_format:: BytesFormat ,
88 get_size:: { GetApparentSize , GetSize } ,
99 hardlink,
10- json_data:: { JsonData , JsonDataBody } ,
10+ json_data:: { JsonData , JsonDataBody , JsonShared , JsonTree } ,
1111 reporter:: { ErrorOnlyReporter , ErrorReport , ProgressAndErrorReporter , ProgressReport } ,
1212 runtime_error:: RuntimeError ,
1313 size,
@@ -66,25 +66,37 @@ impl App {
6666 . map_err ( RuntimeError :: DeserializationFailure ) ?
6767 . body ;
6868
69- macro_rules! visualize {
70- ( $reflection: expr, $bytes_format: expr) => { {
71- let data_tree = $reflection
69+ macro_rules! extract {
70+ ( $tree: expr, $bytes_format: expr) => { {
71+ let JsonTree { tree, shared } = $tree;
72+
73+ let data_tree = tree
7274 . par_try_into_tree( )
7375 . map_err( |error| RuntimeError :: InvalidInputReflection ( error. to_string( ) ) ) ?;
74- Visualizer {
76+ let visualizer = Visualizer {
7577 data_tree: & data_tree,
7678 bytes_format: $bytes_format,
7779 column_width_distribution,
7880 direction,
7981 bar_alignment,
82+ } ;
83+
84+ let JsonShared { details, summary } = shared;
85+ let summary = summary. or_else( || details. map( |details| details. summarize( ) ) ) ;
86+
87+ if let Some ( summary) = summary {
88+ let summary = summary. display( $bytes_format) ;
89+ // visualizer already ends with "\n"
90+ format!( "{visualizer}{summary}\n " )
91+ } else {
92+ visualizer. to_string( )
8093 }
81- . to_string( )
8294 } } ;
8395 }
8496
8597 let visualization = match body {
86- JsonDataBody :: Bytes ( tree) => visualize ! ( tree . tree, bytes_format) ,
87- JsonDataBody :: Blocks ( tree) => visualize ! ( tree . tree, ( ) ) ,
98+ JsonDataBody :: Bytes ( tree) => extract ! ( tree, bytes_format) ,
99+ JsonDataBody :: Blocks ( tree) => extract ! ( tree, ( ) ) ,
88100 } ;
89101
90102 print ! ( "{visualization}" ) ; // it already ends with "\n", println! isn't needed here.
0 commit comments