Cleaner is a cross-platform command-line tool written in Go that recursively scans directories to remove specified files and directories. It offers features like concurrency for faster execution, dry-run mode, exclusion patterns, custom logging formats, and more. Cleaner is configurable via a JSON file, allowing for flexible and powerful cleaning operations.
- Recursive Scanning: Scans directories to any depth.
- Configurable Cleaning: Remove directories and files based on a JSON configuration.
- Concurrency: Utilizes multiple CPU cores for faster execution.
- Dry-Run Mode: Simulate the cleaning process without deleting files.
- Exclusion Patterns: Exclude specific directories and files from being removed.
- Custom Logging Formats: Choose between text or JSON log formats.
- Verbose and Silent Modes: Control console output with the --verbose flag.
- No External Dependencies: Built as static binaries, requiring no dependencies on the target platforms.
Pre-built binaries are available for multiple platforms:
- Windows (amd64)
- macOS (amd64, arm64)
- Linux (amd64, arm64) Download the appropriate binary for your platform from the Releases page. The binaries are self-contained and do not require any external dependencies.
Example:
- For macOS on Apple Silicon (M1/M2):
Download cleaner-darwin-arm64 and make it executable:
chmod +x cleaner-darwin-arm64
- For Windows:
Download cleaner-windows-amd64.exe and run it directly.
If you prefer to build Cleaner from source, ensure you have Go installed (version 1.20 or later).
Steps:
Clone the Repository:
git clone https://github.com/dibe-sh/cleaner.git
cd cleaner
Build the Executable:
go build -ldflags="-s -w" -o cleaner
The -ldflags="-s -w" flags reduce the binary size by stripping debug information. Make the Executable (if necessary):
chmod +x cleaner
./cleaner --root /path/to/start
This command starts the cleaning process from the specified root directory using the default configuration.
./cleaner --help
Displays the list of available command-line flags and their descriptions.
Cleaner uses a JSON configuration file to specify which directories and files to remove or exclude.
{
"directories_to_remove": [
"node_modules",
"dist",
"build",
"bin",
".next",
".turbo",
".idea",
".cache"
],
"file_extensions_to_remove": [".DS_Store", "__debug_bin"],
"exclude_directories": [".git", ".svn"],
"exclude_files": [],
"matchRegex": true
}
- directories_to_remove: List of directory names to remove.
- file_extensions_to_remove: List of file extensions to remove.
- exclude_directories: List of directory names to exclude from removal.
- exclude_files: List of file names to exclude from removal.
You can specify a custom configuration file using the --config flag:
./cleaner --root /path/to/start --config /path/to/custom_config.json
- --root: Root directory to start scanning (default is current directory .).
- --config: Path to the JSON configuration file (default is cleaner_config.json).
- --verbose: Enable verbose console output (true or false, default is true).
- --save-log: Enable saving logs to file (true or false, default is true).
- --dry-run: Simulate the cleaning process without deleting files (default is false).
- --log-format: Log format, either 'text' or 'json' (default is 'text').
- Run with Default Settings
./cleaner --root /path/to/start
- Dry-Run Mode Simulate the cleaning process without deleting any files:
./cleaner --root /path/to/start --dry-run
- Silent Mode without Saving Logs Run without console output and without saving logs:
./cleaner --root /path/to/start --verbose=false --save-log=false
Custom Configuration and Log Format Use a custom configuration file and save logs in JSON format:
./cleaner --root /path/to/start --config custom_config.json --log-format json
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Steps to Contribute
- Fork the repository.
- Create a new branch (git checkout -b feature/YourFeature).
- Commit your changes (git commit -am 'Add some feature').
- Push to the branch (git push origin feature/YourFeature).
- Open a pull request.
Comprehensive documentation is available at Cleaner Documentation.
This project is licensed under the MIT License - see the LICENSE file for details.