Skip to content

Commit 05d656c

Browse files
committed
Enhance output formatting and configuration for GitHub Stats Analyzer
- Updated summary and language tables to utilize configurable styles for headers, borders, and titles, improving visual consistency. - Enhanced the display of additions and deletions in the repository statistics with bold formatting for better visibility. - Introduced new configuration options for table styling in the configuration module, allowing for greater customization of output appearance.
1 parent 79976f9 commit 05d656c

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

github_stats_analyzer/analyzer.py

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@
1414
from rich.console import Console
1515
from rich.table import Table
1616
from rich import print as rprint
17+
from rich import box
1718

1819
from github_stats_analyzer.config import (
19-
GITHUB_API_URL,
20-
MAX_CONCURRENT_REPOS,
20+
AccessLevel,
2121
EXCLUDED_LANGUAGES,
22-
ACCESS_LEVEL_CONFIG,
2322
REPO_LIMITS,
24-
COMMIT_LIMITS
23+
COMMIT_LIMITS,
24+
GITHUB_TOKEN,
25+
DEBUG,
26+
ERROR_HANDLING_CONFIG,
27+
LANGUAGE_DETECTION_CONFIG,
28+
MAX_RETRIES,
29+
OUTPUT_CONFIG,
30+
RETRY_DELAY,
31+
TABLE_STYLE,
32+
MAX_CONCURRENT_REPOS,
33+
GITHUB_API_URL,
2534
)
2635
from github_stats_analyzer.logger import logger, TqdmProgressBar
2736
from github_stats_analyzer.models import (
@@ -318,7 +327,15 @@ def _print_text_results(self):
318327
self.console.print("[bold magenta]Summary Statistics[/bold magenta]")
319328

320329
# Create summary table
321-
summary_table = Table(show_header=True, header_style="bold")
330+
summary_table = Table(
331+
show_header=True,
332+
header_style=TABLE_STYLE.get("header", "bold"),
333+
border_style=TABLE_STYLE.get("border", "rounded"),
334+
box=getattr(box, TABLE_STYLE.get("box", "ROUNDED")),
335+
padding=TABLE_STYLE.get("padding", (1, 1)),
336+
title="Summary",
337+
title_style=TABLE_STYLE.get("title_style", "bold magenta")
338+
)
322339
summary_table.add_column("Category", style="cyan")
323340
summary_table.add_column("Additions", style="green", justify="right")
324341
summary_table.add_column("Deletions", style="red", justify="right")
@@ -327,15 +344,15 @@ def _print_text_results(self):
327344
# Add rows to summary table
328345
summary_table.add_row(
329346
"Total Changes (All Files)",
330-
f"{self.total_additions:,}",
331-
f"{self.total_deletions:,}",
347+
f"[bold green]+{self.total_additions:,}[/bold green]",
348+
f"[bold red]-{self.total_deletions:,}[/bold red]",
332349
f"{self.total_additions - self.total_deletions:,}"
333350
)
334351

335352
summary_table.add_row(
336353
"Code Changes (Code Files Only)",
337-
f"{self.code_additions:,}",
338-
f"{self.code_deletions:,}",
354+
f"[bold green]+{self.code_additions:,}[/bold green]",
355+
f"[bold red]-{self.code_deletions:,}[/bold red]",
339356
f"{self.code_additions - self.code_deletions:,}"
340357
)
341358

@@ -348,8 +365,8 @@ def _print_text_results(self):
348365

349366
summary_table.add_row(
350367
f"Filtered Code Changes\n(excluding {excluded_types})",
351-
f"{filtered_additions:,}",
352-
f"{filtered_deletions:,}",
368+
f"[bold green]+{filtered_additions:,}[/bold green]",
369+
f"[bold red]-{filtered_deletions:,}[/bold red]",
353370
f"{filtered_net:,}"
354371
)
355372

@@ -360,7 +377,15 @@ def _print_text_results(self):
360377
self.console.print("\n[bold magenta]Language Statistics (sorted by lines of code)[/bold magenta]")
361378

362379
# Create language table
363-
language_table = Table(show_header=True, header_style="bold")
380+
language_table = Table(
381+
show_header=True,
382+
header_style=TABLE_STYLE.get("header", "bold"),
383+
border_style=TABLE_STYLE.get("border", "rounded"),
384+
box=getattr(box, TABLE_STYLE.get("box", "ROUNDED")),
385+
padding=TABLE_STYLE.get("padding", (1, 1)),
386+
title="Language Statistics",
387+
title_style=TABLE_STYLE.get("title_style", "bold magenta")
388+
)
364389
language_table.add_column("Language", style="cyan")
365390
language_table.add_column("Bytes", style="green", justify="right")
366391
language_table.add_column("Percentage", style="yellow", justify="right")
@@ -400,7 +425,15 @@ def _print_text_results(self):
400425
self.console.print("\n[bold magenta]Detailed Repository Statistics (sorted by code net change)[/bold magenta]")
401426

402427
# Create repository table
403-
repo_table = Table(show_header=True, header_style="bold")
428+
repo_table = Table(
429+
show_header=True,
430+
header_style=TABLE_STYLE.get("header", "bold"),
431+
border_style=TABLE_STYLE.get("border", "rounded"),
432+
box=getattr(box, TABLE_STYLE.get("box", "ROUNDED")),
433+
padding=TABLE_STYLE.get("padding", (1, 1)),
434+
title="Repository Statistics",
435+
title_style=TABLE_STYLE.get("title_style", "bold magenta")
436+
)
404437
repo_table.add_column("Repository", style="cyan")
405438
repo_table.add_column("Total +/-", style="yellow", justify="right")
406439
repo_table.add_column("Code +/-", style="green", justify="right")
@@ -418,10 +451,14 @@ def _print_text_results(self):
418451
# Format language list
419452
languages = ", ".join(repo.languages.keys())
420453

454+
# Format additions and deletions with more visible styling
455+
total_changes = f"[bold green]+{repo.additions:,}[/bold green]/[bold red]-{repo.deletions:,}[/bold red]"
456+
code_changes = f"[bold green]+{repo.code_additions:,}[/bold green]/[bold red]-{repo.code_deletions:,}[/bold red]"
457+
421458
repo_table.add_row(
422459
repo.name,
423-
f"+{repo.additions:,}/-{repo.deletions:,}",
424-
f"+{repo.code_additions:,}/-{repo.code_deletions:,}",
460+
total_changes,
461+
code_changes,
425462
f"{repo.stars:,}",
426463
created_at,
427464
languages

github_stats_analyzer/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ class AccessLevel:
114114
"header": "bold cyan",
115115
"row": "white",
116116
"footer": "bold green",
117+
"border": "blue",
118+
"box": "ROUNDED",
119+
"padding": (1, 1),
120+
"title_style": "bold magenta",
117121
}
118122

119123
# Repository statistics configuration

0 commit comments

Comments
 (0)