Skip to content

feat: estimate reclaimable space before cleaning (menu option 99)#45

Open
giuseppelanzi wants to merge 1 commit into
jemishavasoya:mainfrom
giuseppelanzi:estimates
Open

feat: estimate reclaimable space before cleaning (menu option 99)#45
giuseppelanzi wants to merge 1 commit into
jemishavasoya:mainfrom
giuseppelanzi:estimates

Conversation

@giuseppelanzi
Copy link
Copy Markdown

Closes #44

What

Adds a read-only menu option 99 that estimates how much disk space
each cleanup entry would free, then redraws the menu with
(Estimate: <size>) next to every option and a total on Clear All.

Why

The tool only shows total free space and a before/after figure. There was no
way to see which options are worth running, or how much each would reclaim,
before deleting anything.

How

  • Strictly read-only: only runs du (bash) / Measure-Object
    (PowerShell). Deletes nothing; behaves identically under --dry-run.
  • Per-entry estimate mirrors exactly the paths the matching cleanup routine
    would remove (kept in a dedicated, commented section).
  • Best-effort for tool-managed caches (npm/yarn/pnpm, Homebrew, …) via their
    known cache dirs; approximate values are prefixed with ~.
  • Flutter and PlatformIO cover the global cache only (fast, deterministic,
    no recursive project scan); Time Machine reports the local snapshot count.
  • macOS sizes use the same binary units as df -h (Gi/Mi/Ki) so the
    estimate matches the existing "Free Space" figure.
  • Implemented in both dev-cleaner.sh and dev-cleaner.ps1.
  • Option 99 is intentionally non-contiguous and categories use stable
    string keys, so existing options 0-N, the "Invalid choice" message and
    any future menu renumbering are unaffected.

Testing

  • bash -n dev-cleaner.sh: passes.
  • shellcheck dev-cleaner.sh: no new findings introduced by this change
    (only pre-existing, unrelated warnings remain; the two intentional
    glob-expansion lines mirror safe_rm and carry a scoped
    # shellcheck disable with a reason).
  • Unit tests of the helpers (human_kb, du_kb_sum, est) and an
    end-to-end estimate_all run against a sandboxed $HOME: all 14
    categories + total populated, approximations marked ~, Time Machine as
    a count, and a before/after filesystem snapshot confirming nothing is
    deleted
    (read-only guarantee, identical under --dry-run).
  • dev-cleaner.ps1: feature implemented at parity (no PowerShell available
    on the dev machine to execute it locally — Windows validation by reviewers
    welcome).

🤖 Generated with Claude Code

Adds a read-only menu option 99 that estimates how much disk space each
cleanup entry would free, then redraws the menu with "(Estimate: <size>)"
plus a total on Clear All. It only runs du / Measure-Object and deletes
nothing (works the same under --dry-run).

- Mirrors the cleanup_* / Clear-* paths so the estimate matches what
  cleanup would remove.
- Best-effort for tool-managed caches; approximate values marked "~".
- Flutter/PlatformIO cover the global cache only; Time Machine reports
  the snapshot count. macOS sizes use df-style binary units (Gi/Mi/Ki).
- Implemented in both dev-cleaner.sh and dev-cleaner.ps1.
- Stable string category keys keep it robust to future menu renumbering.

Refs: jemishavasoya#44

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: estimate reclaimable space before cleaning (menu option 99)

1 participant