@@ -16,8 +16,6 @@ export type StatusReportSection =
1616 | {
1717 kind : "table" ;
1818 title : string ;
19- width : number ;
20- renderTable : TableRenderer ;
2119 columns : readonly TableColumn [ ] ;
2220 rows : Array < Record < string , string > > ;
2321 trailer ?: string | null ;
@@ -41,75 +39,41 @@ export function appendStatusSectionHeading(params: {
4139 params . lines . push ( params . heading ( params . title ) ) ;
4240}
4341
44- function appendStatusLinesSection ( params : {
45- lines : string [ ] ;
46- heading : HeadingFn ;
47- title : string ;
48- body : string [ ] ;
49- } ) {
50- appendStatusSectionHeading ( params ) ;
51- params . lines . push ( ...params . body ) ;
52- }
53-
54- function appendStatusTableSection < Row extends Record < string , string > > ( params : {
55- lines : string [ ] ;
56- heading : HeadingFn ;
57- title : string ;
58- width : number ;
59- renderTable : ( input : { width : number ; columns : TableColumn [ ] ; rows : Row [ ] } ) => string ;
60- columns : readonly TableColumn [ ] ;
61- rows : Row [ ] ;
62- } ) {
63- appendStatusSectionHeading ( params ) ;
64- params . lines . push (
65- params
66- . renderTable ( {
67- width : params . width ,
68- columns : [ ...params . columns ] ,
69- rows : params . rows ,
70- } )
71- . trimEnd ( ) ,
72- ) ;
73- }
74-
75- /** Appends all non-empty report sections in display order. */
42+ /** Appends report sections in display order, honoring explicit empty-section skipping. */
7643export function appendStatusReportSections ( params : {
7744 lines : string [ ] ;
7845 heading : HeadingFn ;
46+ width : number ;
47+ renderTable : TableRenderer ;
7948 sections : StatusReportSection [ ] ;
8049} ) {
8150 for ( const section of params . sections ) {
82- if ( section . kind === "raw" ) {
83- if ( section . skipIfEmpty && section . body . length === 0 ) {
84- continue ;
85- }
86- params . lines . push ( ...section . body ) ;
87- continue ;
88- }
89- if ( section . kind === "lines" ) {
90- if ( section . skipIfEmpty && section . body . length === 0 ) {
91- continue ;
92- }
93- appendStatusLinesSection ( {
94- lines : params . lines ,
95- heading : params . heading ,
96- title : section . title ,
97- body : section . body ,
98- } ) ;
51+ const content = section . kind === "table" ? section . rows : section . body ;
52+ if ( section . skipIfEmpty && content . length === 0 ) {
9953 continue ;
10054 }
101- if ( section . skipIfEmpty && section . rows . length === 0 ) {
55+ if ( section . kind === "raw" ) {
56+ params . lines . push ( ...section . body ) ;
10257 continue ;
10358 }
104- appendStatusTableSection ( {
59+ appendStatusSectionHeading ( {
10560 lines : params . lines ,
10661 heading : params . heading ,
10762 title : section . title ,
108- width : section . width ,
109- renderTable : section . renderTable ,
110- columns : section . columns ,
111- rows : section . rows ,
11263 } ) ;
64+ if ( section . kind === "lines" ) {
65+ params . lines . push ( ...section . body ) ;
66+ continue ;
67+ }
68+ params . lines . push (
69+ params
70+ . renderTable ( {
71+ width : params . width ,
72+ columns : [ ...section . columns ] ,
73+ rows : section . rows ,
74+ } )
75+ . trimEnd ( ) ,
76+ ) ;
11377 if ( section . trailer ) {
11478 params . lines . push ( section . trailer ) ;
11579 }
0 commit comments