mirror of
https://github.com/akadeepesh/contextzip.git
synced 2026-10-20 08:36:20 +02:00
refactor(cli_display): replace boxed panels with a minimal log
- Introduce ok()/warn()/err()/info() as the four output primitives, replacing all rich.Panel/rich.Table usage. - Merge the old 'Scanned N files' + 'Packed N files' steps into one print_scan_and_pack() line. - Drop the contextzip vX.X.X / project-path banner from every command. - Full file listings and exclusion breakdowns move to the report file (report.py) and behind -v/--verbose; the terminal shows one line per step. - Add print_auto_cleanup() and print_redaction_summary() for the two newer background steps (workspace cleanup, secret redaction).
This commit is contained in:
@@ -370,11 +370,36 @@ def print_apply_result(result, *, con: Console = console) -> None:
|
||||
ok("Archived zip to", str(result.applied_zip_path), con=con)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def print_auto_cleanup(result, *, con: Console = console) -> None:
|
||||
"""
|
||||
One quiet, dim line after an automatic cleanup pass — only shown when
|
||||
something was actually removed, so a workspace with nothing stale
|
||||
produces zero extra output. Failures (rare — a locked file, etc.) get
|
||||
a short warning; they never interrupt or roll back the command that
|
||||
was actually run.
|
||||
"""
|
||||
if result.removed:
|
||||
console_line = f"[dim]🧹 Auto-cleaned {len(result.removed)} old file(s) from .contextzip/ · freed {human_size(result.freed_bytes)}[/]"
|
||||
con.print(console_line)
|
||||
|
||||
if result.failed:
|
||||
n = len(result.failed)
|
||||
warn(f"{n} old file{'s' if n != 1 else ''} in .contextzip/ couldn't be auto-cleaned", con=con)
|
||||
for path, reason in result.failed[:5]:
|
||||
con.print(f" [yellow]![/] {path} [dim]{reason}[/]")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Utility
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
def human_size(n: int) -> str:
|
||||
"""Format *n* bytes as a human-readable string (B / KB / MB / GB / TB)."""
|
||||
for unit in ("B", "KB", "MB", "GB"):
|
||||
|
||||
Reference in New Issue
Block a user