use kuizer::detect::{Category, Safety};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Term {
Overview,
DiskUsage,
History,
Trash,
Safety,
Category,
Safe,
Review,
Dependencies,
Build,
Cache,
Temp,
Logs,
TrashContents,
PersonalFiles,
Rule,
Changed,
Size,
Tool,
ProjectArtifacts,
DeveloperCaches,
AppCaches,
SystemCaches,
Toolchains,
Docker,
DuplicateFiles,
Reclaimable,
Groups,
FilesCompared,
Unverified,
DiskFree,
SelectSafe,
Cleanups,
ItemsRemoved,
Freed,
InTrash,
Restore,
Run,
Mode,
Command,
Issues,
GitRepositories,
GcGain,
LooseObjects,
MergedBranches,
Engine,
}
impl Term {
pub fn safety(safety: Safety) -> Self {
match safety {
Safety::Safe => Self::Safe,
Safety::Review => Self::Review,
}
}
pub fn category(category: Category) -> Self {
match category {
Category::Dependencies => Self::Dependencies,
Category::Build => Self::Build,
Category::Cache => Self::Cache,
Category::Temp => Self::Temp,
Category::Logs => Self::Logs,
Category::Trash => Self::TrashContents,
Category::Files => Self::PersonalFiles,
}
}
pub fn title(self) -> &'static str {
match self {
Self::Overview => "Overview",
Self::DiskUsage => "Disk explorer",
Self::History => "History",
Self::Trash => "Delete",
Self::Safety => "Safety",
Self::Category => "Category",
Self::Safe => "safe",
Self::Review => "review",
Self::Dependencies => "dependencies",
Self::Build => "build",
Self::Cache => "cache",
Self::Temp => "temp",
Self::Logs => "Logs",
Self::TrashContents => "Trash",
Self::PersonalFiles => "Personal files",
Self::Rule => "Rule",
Self::Changed => "Changed",
Self::Size => "Size",
Self::Tool => "Tool",
Self::ProjectArtifacts => "Project artifacts",
Self::DeveloperCaches => "Developer caches",
Self::AppCaches => "App caches",
Self::SystemCaches => "System caches",
Self::Toolchains => "Toolchains",
Self::Docker => "Docker",
Self::DuplicateFiles => "Duplicate files",
Self::Reclaimable => "Reclaimable",
Self::Groups => "Groups",
Self::FilesCompared => "Files compared",
Self::Unverified => "Not byte-verified",
Self::DiskFree => "Disk free",
Self::SelectSafe => "Select safe",
Self::Cleanups => "Cleanups",
Self::ItemsRemoved => "Items removed",
Self::Freed => "Freed",
Self::InTrash => "Still in the trash",
Self::Restore => "Trash",
Self::Run => "Run",
Self::Mode => "Mode",
Self::Command => "Command",
Self::Issues => "Issues",
Self::GitRepositories => "Git repositories",
Self::GcGain => "git gc gain",
Self::LooseObjects => "Loose objects",
Self::MergedBranches => "Merged branches",
Self::Engine => "Engine",
}
}
pub fn text(self) -> &'static str {
match self {
Self::Overview => {
"Totals for this scan: what is safe to remove, what needs review, and the largest projects and caches."
}
Self::DiskUsage => {
"Every folder under the scanned folders by the space it takes on disk, largest first. Open a folder to look inside. Folders and files that are not protected can be moved to the trash one at a time."
}
Self::History => {
"Every cleanup kuizer made on this machine, from this window and from the command line, and what is still in the trash."
}
Self::Trash => {
"Removes the selection at once, without asking. Items are deleted for good unless Move to the trash is on in the settings; toolchains and Docker objects are always deleted for good."
}
Self::Safety => {
"How sure kuizer is that removing an item is harmless. safe items are rebuilt by a tool, review items need a look first."
}
Self::Category => {
"What kind of generated data this is: dependencies, build output, cache or temp."
}
Self::Safe => {
"A tool rebuilds this from your project files, for example on the next install or build. Removing it only costs the time to rebuild."
}
Self::Review => {
"Probably generated, but it may hold something a rebuild cannot bring back, such as a virtual environment with local changes or a pinned toolchain. Look before you remove it. Select safe skips review items."
}
Self::Dependencies => {
"Installed packages such as node_modules, Pods and Python virtual environments. Your package manager installs them again."
}
Self::Build => {
"Compiler and bundler output such as target, dist and .next. The next build creates it again."
}
Self::Cache => {
"Data a tool keeps to work faster, such as __pycache__ or .turbo. Tools refill it on their own."
}
Self::Temp => {
"Scratch folders a tool recreates while it runs, such as the Temp folder of a Unity project."
}
Self::Logs => {
"Files programs write to record what they did, such as crash reports and session logs. Programs start new ones."
}
Self::TrashContents => {
"Items you already moved to the trash. Emptying the trash removes them for good."
}
Self::PersonalFiles => {
"Large or old files of your own, such as installers and disk images in Downloads. Nothing can bring them back, so they are never selected in bulk."
}
Self::Rule => {
"The detection rule that matched this item. A rule also checks the project around it, so a dist folder only counts next to a package.json."
}
Self::Changed => {
"How long ago the newest file inside was modified. Old items are usually from projects you no longer work on."
}
Self::Size => {
"Space the item takes on disk, which is what you get back when the trash is emptied."
}
Self::Tool => "The program that owns this cache.",
Self::ProjectArtifacts => {
"Generated folders and files inside your projects, such as dependencies and build output."
}
Self::DeveloperCaches => {
"Caches that package managers and tools keep in your home folder, shared by all projects. Safe caches fill up again on the next install or build."
}
Self::AppCaches => {
"Caches that apps, browsers and the desktop keep in your home folder. Safe caches fill up again on their own."
}
Self::SystemCaches => {
"Downloads and logs your package tools keep. Cleaning one runs that package tool's own cleanup command, which asks for administrator rights in a system dialog when it needs them. Nothing goes to the trash."
}
Self::Toolchains => {
"Installed versions of rustup, nvm, fnm, volta, pyenv, uv, SDKMAN and Go. A default version or one a project under the scanned folder pins is marked review. Removing a version deletes it for good, it does not go to the trash, and the tool downloads it again when needed."
}
Self::Docker => {
"Dangling images, stopped containers, the build cache and volumes no container uses, from Docker and Podman. kuizer removes them through the engine, which refuses anything in use. Removal is permanent: nothing goes to the trash. Volumes can hold data and are always marked review."
}
Self::Engine => {
"Docker or Podman, whichever owns the object. kuizer removes it through the engine, which refuses anything in use. Removal is permanent: nothing goes to the trash."
}
Self::DuplicateFiles => {
"Files with exactly the same content in more than one place. Keeping one copy of each frees the rest."
}
Self::Reclaimable => {
"Space you would get back by keeping one copy of each duplicate and removing the others."
}
Self::Groups => "Each group is a set of files with identical content.",
Self::FilesCompared => {
"Files that had the same size as another file and were hashed to compare their content."
}
Self::Unverified => {
"These files have the same hash, but were not compared byte for byte. A hash match is almost always a real duplicate."
}
Self::DiskFree => "Free space on the disk that holds the scanned folder.",
Self::SelectSafe => {
"Selects every safe item in this tab. Review items stay unselected so you can decide on each one."
}
Self::Cleanups => "Every run of kuizer that moved or deleted items.",
Self::ItemsRemoved => {
"All items removed over time. Items you put back with kuizer restore are counted as restored."
}
Self::Freed => {
"Space actually given back: items deleted permanently, or moved to the trash and since emptied."
}
Self::InTrash => {
"Removed items that are still in the trash. Restore in the table below or kuizer restore puts them back until the trash is emptied."
}
Self::Restore => {
"Whether this cleanup is still in the trash. Restore puts what is left back where it was. Items restored before or emptied from the trash cannot come back."
}
Self::Run => {
"The id of the cleanup. Run kuizer restore with this id, for example kuizer restore s4, to put it back from the trash."
}
Self::Mode => {
"trash moves items to the trash, permanent deletes them for good, and dry run only showed what would happen."
}
Self::Command => "The command that started this cleanup.",
Self::Issues => {
"Folders the scan could not read or chose to skip, such as other disks or protected folders. Nothing in them is listed."
}
Self::GitRepositories => {
"Git repositories under the scanned folders that have loose objects git gc can pack, or local branches already merged into the default branch."
}
Self::GcGain => {
"An estimate of what git gc frees: the loose objects it packs and the garbage it removes. Packing keeps a compressed copy, so the real gain is a little lower."
}
Self::LooseObjects => {
"Objects git stores as separate files. Every commit adds some until git gc packs them into one compressed file."
}
Self::MergedBranches => {
"Local branches whose last commit is already in the default branch. Deleting one loses nothing: the commits stay in the default branch and remote branches are never touched."
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn safety_and_category_map_to_their_terms() {
assert_eq!(
Term::safety(Safety::Review).title(),
Safety::Review.as_str()
);
for category in Category::ALL {
assert_eq!(Term::category(category).title(), category.as_str());
}
}
}