@@ -318,6 +318,26 @@ const (
318318 colorGray = "\033 [90m"
319319)
320320
321+ // colorize wraps text with an ANSI colour code and reset.
322+ func colorize (text , color string ) string {
323+ return color + text + colorReset
324+ }
325+
326+ // bold wraps text with ANSI bold formatting.
327+ func bold (text string ) string {
328+ return colorBold + text + colorReset
329+ }
330+
331+ // tableCell formats a left-aligned cell with the given width and colour.
332+ func tableCell (text string , width int , color string ) string {
333+ return fmt .Sprintf ("%s%-*s%s" , color , width , text , colorReset )
334+ }
335+
336+ // tableBorder returns a horizontal border segment of the given width.
337+ func tableBorder (width int ) string {
338+ return strings .Repeat ("═" , width + 2 )
339+ }
340+
321341// printLibraryList displays a formatted table of all libraries
322342func printLibraryList (libs []* Library ) {
323343 // Calculate column widths
@@ -345,31 +365,33 @@ func printLibraryList(libs []*Library) {
345365 }
346366
347367 // Print header
348- fmt .Printf ("\n %s%s╔═" , colorBold , colorCyan )
349- fmt .Printf ("%s" , strings .Repeat ("═" , maxName + 6 ))
350- fmt .Printf ("╦═%s" , strings .Repeat ("═" , maxPlatform + 2 ))
351- fmt .Printf ("╦═%s" , strings .Repeat ("═" , maxBuildSys + 2 ))
352- fmt .Printf ("╦═%s" , strings .Repeat ("═" , maxLinkLibs + 2 ))
353- fmt .Printf ("╗%s\n " , colorReset )
354-
355- fmt .Printf ("%s║%s %s #%s %s%-*s%s %s║%s %-*s %s ║%s %-*s %s ║%s %-*s %s ║%s\n " ,
368+ fmt .Printf ("\n %s╔═%s╦%s╦%s╦%s╗%s\n " ,
369+ colorize ("" , colorBold + colorCyan ),
370+ tableBorder (maxName + 3 ),
371+ tableBorder (maxPlatform ),
372+ tableBorder (maxBuildSys ),
373+ tableBorder (maxLinkLibs ),
374+ colorReset )
375+
376+ fmt .Printf ("%s║%s %s %s %s ║%s %s %s║%s %s %s║%s %s %s║%s\n " ,
356377 colorCyan , colorReset ,
357- colorBold + colorYellow , colorReset ,
358- colorBold + colorYellow , maxName , "Library" , colorReset ,
378+ tableCell ( "#" , 2 , colorBold + colorYellow ) ,
379+ tableCell ( "Library" , maxName , colorBold + colorYellow ) ,
359380 colorCyan , colorReset ,
360- maxPlatform , "Platform" ,
381+ tableCell ( "Platform" , maxPlatform , colorReset ) ,
361382 colorCyan , colorReset ,
362- maxBuildSys , "Build System" ,
383+ tableCell ( "Build System" , maxBuildSys , colorReset ) ,
363384 colorCyan , colorReset ,
364- maxLinkLibs , "Link Libraries" ,
385+ tableCell ( "Link Libraries" , maxLinkLibs , colorReset ) ,
365386 colorCyan , colorReset )
366387
367- fmt .Printf ("%s╠═" , colorCyan )
368- fmt .Printf ("%s" , strings .Repeat ("═" , maxName + 6 ))
369- fmt .Printf ("╬═%s" , strings .Repeat ("═" , maxPlatform + 2 ))
370- fmt .Printf ("╬═%s" , strings .Repeat ("═" , maxBuildSys + 2 ))
371- fmt .Printf ("╬═%s" , strings .Repeat ("═" , maxLinkLibs + 2 ))
372- fmt .Printf ("╣%s\n " , colorReset )
388+ fmt .Printf ("%s╠═%s╬%s╬%s╬%s╣%s\n " ,
389+ colorCyan ,
390+ tableBorder (maxName + 3 ),
391+ tableBorder (maxPlatform ),
392+ tableBorder (maxBuildSys ),
393+ tableBorder (maxLinkLibs ),
394+ colorReset )
373395
374396 // Print rows
375397 for i , lib := range libs {
@@ -395,26 +417,27 @@ func printLibraryList(libs []*Library) {
395417 linkLibsColor = colorGray
396418 }
397419
398- fmt .Printf ("%s║%s %s%s%s %s%-*s %s ║%s %-* s %s ║%s %-* s %s ║%s %s%-*s%s %s ║%s\n " ,
420+ fmt .Printf ("%s║%s %s %s %s ║%s %s %s║%s %s %s║%s %s %s║%s\n " ,
399421 colorCyan , colorReset ,
400- colorBlue + colorBold , num , colorReset ,
401- nameColor , maxName , lib . Name ,
422+ tableCell ( num , 2 , colorBlue + colorBold ) ,
423+ tableCell ( lib . Name , maxName , nameColor ) ,
402424 colorCyan , colorReset ,
403- maxPlatform , platform ,
425+ tableCell ( platform , maxPlatform , colorReset ) ,
404426 colorCyan , colorReset ,
405- maxBuildSys , buildSys ,
427+ tableCell ( buildSys , maxBuildSys , colorReset ) ,
406428 colorCyan , colorReset ,
407- linkLibsColor , maxLinkLibs , linkLibsDisplay , colorReset ,
429+ tableCell ( linkLibsDisplay , maxLinkLibs , linkLibsColor ) ,
408430 colorCyan , colorReset )
409431 }
410432
411433 // Print footer
412- fmt .Printf ("%s╚═" , colorCyan )
413- fmt .Printf ("%s" , strings .Repeat ("═" , maxName + 6 ))
414- fmt .Printf ("╩═%s" , strings .Repeat ("═" , maxPlatform + 2 ))
415- fmt .Printf ("╩═%s" , strings .Repeat ("═" , maxBuildSys + 2 ))
416- fmt .Printf ("╩═%s" , strings .Repeat ("═" , maxLinkLibs + 2 ))
417- fmt .Printf ("╝%s\n \n " , colorReset )
434+ fmt .Printf ("%s╚═%s╩%s╩%s╩%s╝%s\n \n " ,
435+ colorCyan ,
436+ tableBorder (maxName + 3 ),
437+ tableBorder (maxPlatform ),
438+ tableBorder (maxBuildSys ),
439+ tableBorder (maxLinkLibs ),
440+ colorReset )
418441
419442 // Summary
420443 totalLibs := len (libs )
0 commit comments