Add --json command-line flag to mo status that outputs system metrics
in JSON format without requiring a TTY environment.
This enables:
- Integration with GUI applications (e.g., native macOS apps)
- Use in automation scripts and monitoring systems
- Piping output to tools like jq for data extraction
- Recording metrics for analysis
Implementation:
- Add JSON struct tags to all metric types
- Add --json flag using Go's flag package
- Implement runJSONMode() for one-time metric collection
- Refactor main() to support both TUI and JSON modes
- Maintain 100% backward compatibility (default TUI unchanged)
Testing:
- All 454 existing tests pass
- JSON output validated with jq and python json.tool
- Pipeline and redirection work correctly
- No breaking changes to existing functionality
- Add simctl availability check before attempting cleanup
- Capture and analyze error output for better diagnostics
- Implement fallback: manual deletion when simctl fails
- Provide specific error hints (permission, in-use, service issues)
- Skip early when no unavailable simulators exist
- Show partial success status when some deletions fail
Error scenarios now handled:
- simctl not available → skip with friendly message
- Permission denied → show hint and try manual deletion
- Device in use → show hint and try manual deletion
- CoreSimulator service issues → show hint
- Partial failures → show "partially cleaned X/Y"
Fixes#520
Start sudo keepalive after authorization and clean it up on all failure/success paths to avoid repeated password prompts and overlapping update UI output. Closes#514.
Cache Homebrew formula output and use shell string matching to prevent pipefail SIGPIPE races that could misreport script installs as manual. Closes#513.
On macOS 15+, /usr/bin/pip3 exists as a stub that triggers Command Line
Tools installation dialog. The previous check only verified command
existence, causing false "pip cache · would clean" output for users
without actual pip3 installed.
Now verifies pip3 is functional by checking `pip3 --version` before
attempting cleanup.
Fixes#512
Remove unused functions from base.sh and ui.sh:
- base.sh: is_interactive, spinner stack management, get_terminal_info, validate_terminal_environment
- ui.sh: with_spinner
Net reduction: ~166 lines of dead code
- Switch bytes_to_human (shell) and humanizeBytes (Go) from Base-2
(1024) to Base-10 (1000) to match Apple's storage calculation
standard since Snow Leopard
- Add proper decimal rounding instead of truncation
- Use mdls kMDItemLogicalSize for .app bundles to avoid APFS clone
file undercounting by du
Fixes#511
Use a fast `defaults read` pre-check before spawning any tmutil
process. On machines without Time Machine configured the check
returns instantly, avoiding the spinner and the 2-3s tmutil timeout.
Affected locations:
- lib/clean/system.sh: clean_time_machine_failed_backups()
- lib/clean/system.sh: clean_local_snapshots()
- lib/clean/user.sh: local snapshot hint in system hints
Add support for cleaning old aerial wallpaper videos in:
/Users/user/Library/Application Support/com.apple.wallpaper/aerials/videos
These video files can consume significant disk space (up to 50GB+) and
are safe to remove - macOS will re-download them on demand.
Uses MOLE_SUPPORT_CACHE_AGE_DAYS (default 30 days) to avoid removing
recently used wallpapers.
Closes#508
This commit addresses the issue #506 where mole would exit prematurely
during application support scanning.
Changes:
1. Remove 4 redundant pipefail disable/restore blocks:
- safe_find_delete() in lib/core/file_ops.sh
- safe_sudo_find_delete() in lib/core/file_ops.sh
- fix_broken_preferences() in lib/optimize/maintenance.sh
- opt_saved_state_cleanup() in lib/optimize/tasks.sh
These were unnecessary because process substitution (< <(cmd)) is not
affected by pipefail - only real pipelines (cmd1 | cmd2) are.
2. Fix real bug in fix_broken_preferences():
- Add || true to ((broken_count++)) on lines 35 and 55
- This prevents set -e from exiting when broken_count starts at 0
Fixes#506