rules

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package rules defines the data model for scannable/cleanable disk items and the OS-aware catalog that classifies them. It has no terminal dependency so a GUI can reuse it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category int

Category groups items for display.

const (
	Caches Category = iota
	BuildArtifacts
	PackageStores
	Simulators
	LargeFiles
	AppData
)

func (Category) String

func (c Category) String() string

type CleanMethod

type CleanMethod int

CleanMethod is how an item is reclaimed.

const (
	Remove  CleanMethod // rm -rf
	Trash               // move to OS trash
	Command             // run Item.Command instead of deleting a path
)

type Entry

type Entry struct {
	PathTemplate string
	Label        string
	Category     Category
	Tier         Tier
	Method       CleanMethod
	Command      []string
}

Entry is a catalog rule. PathTemplate uses "~" for the home dir.

func Catalog

func Catalog(goos, home string) []Entry

Catalog returns the classification rules for the given GOOS and home dir.

func (Entry) Expand

func (e Entry) Expand(home string) string

Expand resolves "~" to home. Returns "" for command-token templates that do not start with "~".

type Item

type Item struct {
	Path     string
	Label    string
	Bytes    int64
	Category Category
	Tier     Tier
	Method   CleanMethod
	Command  []string
	Source   Source
}

Item is one scannable/cleanable thing.

func ClassifyHeuristic

func ClassifyHeuristic(path string) Item

ClassifyHeuristic classifies a path discovered by the heuristic walk that the catalog did not already cover. Default: user data, treated as a large file.

func (Item) EffectiveMethod

func (i Item) EffectiveMethod() CleanMethod

EffectiveMethod resolves the method, deriving from Tier when unset.

func (Item) Selectable

func (i Item) Selectable() bool

Selectable reports whether the user may select this item for cleaning.

type Source

type Source int

Source records how an item was discovered.

const (
	CatalogSource Source = iota
	Heuristic
)

type Tier

type Tier int

Tier expresses cleanup safety.

const (
	Safe   Tier = iota // regenerates automatically; hard-delete is fine
	Review             // real user data; needs judgment; trash by default
	Keep               // protected; never selectable
)

func (Tier) String

func (t Tier) String() string

Jump to

Keyboard shortcuts

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