Skip to content

feat(cli): redesign the interactive CLI with a terminal UI toolkit - #192

Open
ingvarch wants to merge 21 commits into
momenbasel:mainfrom
ingvarch:feat/cli-terminal-ui
Open

ingvarch wants to merge 21 commits into
momenbasel:mainfrom
ingvarch:feat/cli-terminal-ui

Conversation

@ingvarch

Copy link
Copy Markdown

What does this PR do?

Gives the PureMac CLI a full terminal interface with framed windows, dialogs, progress and color. The scripting paths (--plain, --json, --dry-run, --force) keep their current behaviour.

  • New internal SwiftPM target TerminalUI, with no new dependencies: a cell buffer that handles wide characters, styles, row and column layout, windows, dialogs, scrollbar, key hints, gauges, text input, a spinner, and a loop that redraws while work runs on a background thread. Term and TerminalSession moved into it.
  • The cleanup flow stays inside the UI. Return on the selection screen opens a confirmation dialog with Cancel focused; it shows the total and how many selected items the search hides. Removal shows a spinner and the current path, and the result opens in a dialog and is printed to the terminal afterwards. --plain still prints every selected path and asks y/N.
  • Scans show progress: clean per category, purge with the current folder and what was found so far, and the storage explorer adds folders as they are measured. Esc cancels, also inside a large folder.
  • From the home menu, Project cleanup and Explore storage ask before they start, since they can take minutes.
  • Sizes are colored by magnitude: under 100 MB green, under 1 GB yellow, 1 GB and more red. This applies in the UI and in plain reports on a TTY.
  • System status shows three panels: This Mac (chip, cores, memory, macOS, model, uptime), Memory with the macOS memory pressure level, and Storage with the free share in color. Memory uses binary units, as About This Mac does.
  • Preferences can be edited: the artifact age with left and right presets, the project folders that purge scans (a new setting; they were hard-coded), and protected paths (add and remove, with a confirmation before protection is removed).
  • The settings files are created on the first interactive start. Project folders are stored in ~/.config/puremac/projects, so config.json stays readable by release 1.1.1.
  • README text and screenshots are updated.

Fixed along the way:

  • After a full-height frame, the screen clear (\e[J) erased the bottom-right cell in xterm-like terminals.
  • In the storage explorer at 40x12, a long focused path lost its end, which is the folder name.

The version stays at 1.1.1 so the maintainer can bump it with the release. The changes fit a minor release (1.2.0): new features, and existing flags and settings files keep working.

Left for later:

  • Translations: the CLI is English only.
  • Removal cannot be cancelled midway; Ctrl+C ends the process, as before.
  • A cleanup with skipped or failed items still ends the home menu with exit status 1, as before.

Type of change

  • Bug fix
  • New feature
  • Performance improvement
  • UI/UX enhancement
  • Documentation
  • Other (describe)

Testing

  • Tested on macOS Ventura (13.x)
  • Tested on macOS Sonoma (14.x)
  • Tested on macOS Sequoia (15.x)

swift test in cli/ passes (560 tests). Checked by hand in tmux at 40x12, 64x18, 80x20 and 100x30, with and without NO_COLOR, on macOS 27.0.1.

Screenshots

PureMac CLI workspace

Choosing project artifacts with size colors and a running total

@ingvarch

Copy link
Copy Markdown
Author
00-menu 01-purge-ask 02-purge-scanning 03-select 04-confirm 05-removing 06-removed 07-explore-ask 08-explore-measuring 09-explore-browse 10-status 11-preferences 12-project-folders 13-protected-paths 14-protected-remove

This branch has not been deployed

No deployments
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.

1 participant