|
28 | 28 | from cli_audit.detection import audit_tool_installation # noqa: E402 |
29 | 29 | from cli_audit.snapshot import load_snapshot, write_snapshot, render_from_snapshot, get_snapshot_path # noqa: E402 |
30 | 30 | from cli_audit.render import render_table, print_summary, status_icon # noqa: E402 |
31 | | -from cli_audit.collectors import get_github_rate_limit # noqa: E402 |
| 31 | +from cli_audit.collectors import get_github_rate_limit, get_github_rate_limit_help # noqa: E402 |
32 | 32 | from cli_audit import collectors # noqa: E402 |
33 | 33 | from cli_audit.logging_config import setup_logging # noqa: E402 |
34 | 34 | # Split file support (Phase 2.1) |
@@ -353,10 +353,27 @@ def cmd_update(args: argparse.Namespace) -> int: |
353 | 353 | if rate_limit: |
354 | 354 | remaining = rate_limit.get("remaining", 0) |
355 | 355 | limit = rate_limit.get("limit", 0) |
| 356 | + authenticated = rate_limit.get("authenticated", False) |
| 357 | + token_source = rate_limit.get("token_source", "") |
| 358 | + |
| 359 | + # Build status message |
| 360 | + auth_info = "" |
| 361 | + if authenticated: |
| 362 | + if token_source == "gh_cli": |
| 363 | + auth_info = " (via gh CLI)" |
| 364 | + elif token_source == "GITHUB_TOKEN": |
| 365 | + auth_info = " (via GITHUB_TOKEN)" |
| 366 | + |
356 | 367 | if remaining < limit * 0.2: # Warn if less than 20% remaining |
357 | | - print(f"⚠️ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 368 | + print(f"⚠️ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
| 369 | + if not authenticated: |
| 370 | + print(get_github_rate_limit_help(), file=sys.stderr) |
| 371 | + elif not authenticated and limit == 60: |
| 372 | + # Unauthenticated with default limit - suggest authentication |
| 373 | + print(f"ℹ️ GitHub rate limit: {remaining}/{limit} remaining (unauthenticated)", file=sys.stderr) |
| 374 | + print(get_github_rate_limit_help(), file=sys.stderr) |
358 | 375 | else: |
359 | | - print(f"✓ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 376 | + print(f"✓ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
360 | 377 |
|
361 | 378 | print(f"# Collecting fresh data for {total} tools...", file=sys.stderr) |
362 | 379 | est_time = int((total / MAX_WORKERS) * 3 * 1.5) |
@@ -487,10 +504,20 @@ def cmd_update(args: argparse.Namespace) -> int: |
487 | 504 | if rate_limit: |
488 | 505 | remaining = rate_limit.get("remaining", 0) |
489 | 506 | limit = rate_limit.get("limit", 0) |
490 | | - if remaining < limit * 0.2: # Warn if less than 20% remaining |
491 | | - print(f"⚠️ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 507 | + authenticated = rate_limit.get("authenticated", False) |
| 508 | + token_source = rate_limit.get("token_source", "") |
| 509 | + |
| 510 | + auth_info = "" |
| 511 | + if authenticated: |
| 512 | + if token_source == "gh_cli": |
| 513 | + auth_info = " (via gh CLI)" |
| 514 | + elif token_source == "GITHUB_TOKEN": |
| 515 | + auth_info = " (via GITHUB_TOKEN)" |
| 516 | + |
| 517 | + if remaining < limit * 0.2: |
| 518 | + print(f"⚠️ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
492 | 519 | else: |
493 | | - print(f"✓ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 520 | + print(f"✓ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
494 | 521 |
|
495 | 522 | # Suggest package manager upgrades |
496 | 523 | from cli_audit.catalog import suggest_package_manager_upgrades |
@@ -626,7 +653,21 @@ def cmd_update_baseline(args: argparse.Namespace) -> int: |
626 | 653 | if rate_limit: |
627 | 654 | remaining = rate_limit.get("remaining", 0) |
628 | 655 | limit = rate_limit.get("limit", 0) |
629 | | - print(f"✓ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 656 | + authenticated = rate_limit.get("authenticated", False) |
| 657 | + token_source = rate_limit.get("token_source", "") |
| 658 | + |
| 659 | + auth_info = "" |
| 660 | + if authenticated: |
| 661 | + if token_source == "gh_cli": |
| 662 | + auth_info = " (via gh CLI)" |
| 663 | + elif token_source == "GITHUB_TOKEN": |
| 664 | + auth_info = " (via GITHUB_TOKEN)" |
| 665 | + |
| 666 | + if not authenticated and limit == 60: |
| 667 | + print(f"ℹ️ GitHub rate limit: {remaining}/{limit} remaining (unauthenticated)", file=sys.stderr) |
| 668 | + print(get_github_rate_limit_help(), file=sys.stderr) |
| 669 | + else: |
| 670 | + print(f"✓ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
630 | 671 |
|
631 | 672 | print(f"# Collecting upstream versions for {total} tools...", file=sys.stderr) |
632 | 673 |
|
@@ -671,7 +712,17 @@ def cmd_update_baseline(args: argparse.Namespace) -> int: |
671 | 712 | if rate_limit: |
672 | 713 | remaining = rate_limit.get("remaining", 0) |
673 | 714 | limit = rate_limit.get("limit", 0) |
674 | | - print(f"✓ GitHub rate limit: {remaining}/{limit} remaining", file=sys.stderr) |
| 715 | + authenticated = rate_limit.get("authenticated", False) |
| 716 | + token_source = rate_limit.get("token_source", "") |
| 717 | + |
| 718 | + auth_info = "" |
| 719 | + if authenticated: |
| 720 | + if token_source == "gh_cli": |
| 721 | + auth_info = " (via gh CLI)" |
| 722 | + elif token_source == "GITHUB_TOKEN": |
| 723 | + auth_info = " (via GITHUB_TOKEN)" |
| 724 | + |
| 725 | + print(f"✓ GitHub rate limit: {remaining}/{limit} remaining{auth_info}", file=sys.stderr) |
675 | 726 |
|
676 | 727 | return 0 |
677 | 728 |
|
|
0 commit comments