# CustomCleaner

A Go-based desktop graphical application using Qt bindings (miqt) that acts as a system cleaner for Windows. Also includes a dedicated CLI binary for automation.

## Features

- **Simple Tab**: Scan and remove temporary files based on predefined or custom paths
- **Advanced Tab**: Not implemented yet
- **Disk Analyzer Tab**: Visual representation of disk usage (like WinDirStat)
- **About Tab**: Shows build/runtime info, links, and license
- **CLI Mode**: Run without GUI for automation

## Requirements

- Windows OS 10 or Later

## Installation

1. Unzip
2. Execute

## Building

```bash
make
```

### Embedding build metadata
We can embed build info (version, commit, build time, LOC) into the About tab via ldflags:
```bash
go build -o CustomCleaner.exe -ldflags "\
-H windowsgui \
-X customcleaner/internal/buildinfo.AppVersion=${VERSION} \
-X customcleaner/internal/buildinfo.BuildDate=$(shell date -Iseconds) \
-X customcleaner/internal/buildinfo.GitCommit=$(shell git rev-parse --short HEAD) \
-X customcleaner/internal/buildinfo.Build=${BUILD} \
-X customcleaner/internal/buildinfo.Lines=$(git ls-files | xargs wc -l | tail -n1 | awk '{print $1}')" \
./cmd/cleaner
```
Use the same ldflags (without `-H windowsgui`) for the console build if desired.

## Usage

### GUI Mode
Simply run the executable:
```bash
CustomCleaner.exe
```

### CLI Modes

#### GUI binary in CLI mode
Elevate privilegies:
```bash
CustomCleaner.exe -elev
```

#### Dedicated CLI binary
Scan for files:
```bash
customcleaner-cli.exe -scan
```

Scan and remove files:
```bash
customcleaner-cli.exe -scan -remove
```

Optional elevation (Windows):
```bash
customcleaner-cli.exe -elev -scan
```

Simulation path and dummy file generation (for testing):
```bash
customcleaner-cli.exe -simul -testcreate -scan
```
`-simul` forces the scan path to `C:\temp22`; `-testcreate` writes 100 small dummy files there before scanning.

## Configuration

Create a `cleaner.ini` file in the same directory as the executable to customize scan paths:

```ini
[scan]
C:\Windows\Temp=*.*
C:\Users\YourName\AppData\Local\Temp=*.tmp
```

Format: `path=pattern`

If no `cleaner.ini` exists, the application uses default Windows temporary directories.

## Default Scan Locations

- `%TEMP%`
- `%LOCALAPPDATA%\Temp`
- `%WINDIR%\Temp`
- `%WINDIR%\Prefetch`

## Project Structure

```
CustomCleaner/
├── main.go                          # Entry point (GUI / CLI switch)
├── internal/
│   ├── cli/                         # CLI mode implementation
│   ├── buildinfo/                   # Build-time metadata (ldflags)
│   ├── config/                      # Configuration parser
│   ├── elevation/                   # Windows privilege elevation
│   ├── scanner/                     # File scanning and removal
│   ├── diskanalyzer/                # Disk usage analysis
│   └── gui/                         # Qt GUI implementation
│       ├── gui.go
│       ├── mainwindow.go
│       ├── simpletab.go
│       ├── advancedtab.go
│       ├── diskanalyzertab.go
│       └── abouttab.go
├── cmd/
│   ├── cleaner/                     # GUI/CLI combo entry
│   └── cleaner-cli/                 # Dedicated CLI entry
└── cleaner.ini.example              # Example configuration
```

## License

This project is provided as-is for internal use only.
