Skip to content

Commit 800b4d8

Browse files
committed
use a super table
1 parent 5ee1016 commit 800b4d8

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

internal/cmd/root.go

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -532,22 +532,51 @@ func displayTableStats(stats *StatsCollector) {
532532
}
533533
fmt.Println(bot)
534534

535-
// Print summary row
536-
fmt.Printf("\nSummary: Processed %d repos | Combined: %d | Skipped (MC): %d | Skipped (DNM): %d | Time: %s\n",
537-
stats.ReposProcessed,
538-
stats.PRsCombined,
539-
stats.PRsSkippedMergeConflict,
540-
stats.PRsSkippedCriteria,
541-
stats.EndTime.Sub(stats.StartTime).Round(time.Second),
535+
// Print horizontal line (same as sep) to section off summary
536+
fmt.Println(sep)
537+
538+
// Print summary row in table style
539+
summaryLabel := fmt.Sprintf("%-*s", repoCol, "Summary")
540+
summaryCombined := fmt.Sprintf("%*d", colWidths[1], stats.PRsCombined)
541+
summarySkipped := fmt.Sprintf("Skipped (MC): %d, (DNM): %d", stats.PRsSkippedMergeConflict, stats.PRsSkippedCriteria)
542+
if len(summarySkipped) > colWidths[2] {
543+
summarySkipped = summarySkipped[:colWidths[2]-1] + "…"
544+
}
545+
summarySkipped = fmt.Sprintf("%-*s", colWidths[2], summarySkipped)
546+
summaryStatus := fmt.Sprintf("Processed: %d | Time: %s", stats.ReposProcessed, stats.EndTime.Sub(stats.StartTime).Round(time.Second))
547+
if len(summaryStatus) > colWidths[3] {
548+
summaryStatus = summaryStatus[:colWidths[3]-1] + "…"
549+
}
550+
summaryStatus = fmt.Sprintf("%-*s", colWidths[3], summaryStatus)
551+
fmt.Printf(
552+
"│ %-*s │ %s │ %s │ %s │\n",
553+
repoCol, summaryLabel,
554+
summaryCombined,
555+
summarySkipped,
556+
summaryStatus,
542557
)
543558

544-
// Print PR links block
559+
// Print horizontal line (same as sep) to section off PR links
560+
fmt.Println(sep)
561+
562+
// Print PR links block in table style
545563
if len(stats.CombinedPRLinks) > 0 {
546-
fmt.Println("\nLinks to Combined PRs:")
547-
for _, link := range stats.CombinedPRLinks {
548-
fmt.Println("-", link)
564+
prLinksLabel := fmt.Sprintf("%-*s", repoCol, "Links to Combined PRs")
565+
for i, link := range stats.CombinedPRLinks {
566+
prLink := link
567+
if len(prLink) > colWidths[1]+colWidths[2]+colWidths[3]+6 {
568+
prLink = prLink[:colWidths[1]+colWidths[2]+colWidths[3]+3] + "…"
569+
}
570+
if i == 0 {
571+
fmt.Printf("│ %-*s │ %-*s │\n", repoCol, prLinksLabel, colWidths[1]+colWidths[2]+colWidths[3]+6, prLink)
572+
} else {
573+
fmt.Printf("│ %-*s │ %-*s │\n", repoCol, "", colWidths[1]+colWidths[2]+colWidths[3]+6, prLink)
574+
}
549575
}
550576
}
577+
578+
// Print bottom border
579+
fmt.Println(bot)
551580
}
552581

553582
// pad returns a string of n runes of s (usually "─")

0 commit comments

Comments
 (0)