Help us shape the future of Go! Take the 2026 Go Developer Survey

tui

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tui implements CleanX's Bubble Tea terminal UI, replacing the raw ANSI escape sequences of the reference script with a proper full-screen, terminal-agnostic interface. It drives the whole interactive flow:

settings → scan (spinner) → multi-select (checkboxes, sizes, drill-down)
         → confirm (destructive) → run (progress bar) → summary (+ Time
         Machine snapshots)

All side effects — scanning, deleting, running tool cleanups, Time Machine — are injected via Actions, so the model's state transitions are decoupled from the OS and the pure selection/toggle logic is unit-tested.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions

type Actions struct {
	Scan         func(scan.Options) scan.Result
	ToolCleanups func() []toolclean.Cleanup
	DeletePaths  func(paths []string) cleaner.Result
	RunTool      func(c toolclean.Cleanup) (freedKB int64, err error)
	ListSnaps    func() []string
	DeleteSnap   func(id string) error
}

Actions injects the effectful operations the UI performs. Wiring lives in cmd; tests supply fakes.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the Bubble Tea model.

func New

func New(actions Actions, opts scan.Options, dryRun, bySize, skipSettings bool) Model

New builds the initial model. When skipSettings is true the model starts scanning immediately (used by the --run/--dry-run flags), otherwise it opens on the settings screen.

func (Model) FreedKB

func (m Model) FreedKB() int64

FreedKB exposes the reclaimed total for post-run reporting.

func (Model) Init

func (m Model) Init() tea.Cmd

Init implements tea.Model. When the model was constructed to skip settings it kicks off the scan (and spinner) immediately.

func (Model) Quitting

func (m Model) Quitting() bool

Quitting reports whether the user ended the session (used by cmd to know the program exited normally).

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update implements tea.Model.

func (Model) View

func (m Model) View() string

View implements tea.Model.

func (Model) WasDryRun

func (m Model) WasDryRun() bool

WasDryRun reports whether the run was in preview mode (no deletions).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL