Skip to main content

🫰 Thanos - Eliminate half of all files with a snap. Perfectly balanced, as all things should be.

Project description

🫰 Thanos

"Perfectly balanced, as all things should be."

A glove

A Python CLI tool that randomly eliminates half of the files in a directory with a snap. Inspired by Marvel's Thanos and his infamous snap.

Test Python application Python 3.9+ Coverage Status License: MIT

⚠️ Warning

This tool permanently deletes files! Use --dry-run first to preview what would be deleted. Deleted files cannot be recovered. Use at your own risk!

✨ Features

  • ⚖️ Weighted Selection: Configure probabilities based on file age, size, or extension.
  • 🛡️ Smart Protections: Automatically protects .git, node_modules, venv, and system files.
  • 🚫 Custom Ignore: Support for .thanosignore using gitignore syntax.
  • 🎲 Reproducibility: Use seeds to ensure the exact same files are selected every time.
  • 📁 Recursive Support: Optionally include files in subdirectories.

📦 Installation

Using uv (recommended)

uv add thanos-cli
uv pip install thanos-cli   # <- if you don't have pyproject.toml

Using pip

pip install thanos-cli

🚀 Quick Start

1. Initialize Configuration

Create default .thanosignore and .thanosrc.json files in your project:

thanos init

2. Preview the Snap

Always start with a dry run to see the "dead" files without deleting them:

thanos snap --dry-run

3. Execute

When you are ready to restore balance:

thanos snap

⚙️ Configuration

Thanos supports advanced configuration to control the chaos.

.thanosignore

Protect specific files or folders from being snapped (gitignore syntax):

# Protect specific folders
src/
important_docs/
!debug.log

.thanosrc.json

Define weights (0.0 to 1.0) to make specific files more or less likely to be eliminated.

  • 0.0: Never eliminate
  • 0.5: Neutral (Default)
  • 1.0: Always eliminate

Supported weight types:

  • by_extension — e.g., target .tmp or .log files
  • by_age_days — e.g., target files older than 30+ days
  • by_size_mb — e.g., target files larger than 100+ MB

See docs/configuration.md for the full schema.

📖 Commands

The CLI structure:

  • thanos init — Generate configuration files.
  • thanos snap [DIRECTORY] — Main command to eliminate files.

Options:

  • -r, --recursive — Include subdirectories
  • -d, --dry-run — Preview without deleting
  • --seed <INT> — Set seed for reproducibility
  • --no-protect — Disable protections (dangerous)

For detailed usage, see docs/usage.md.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤔 FAQ

Q: Can I recover deleted files? A: No, files are permanently deleted. Always use --dry-run first!

Q: How are files selected? A: Randomly, but you can bias the selection using weights in .thanosrc.json.

Q: What is protected by default? A: .git, .svn, node_modules, venv, __pycache__, .env, and more.

Q: What if I have an odd number of files? A: If you have 11 files, 5 will be deleted (11 // 2 = 5) and 6 will remain.

🙏 Acknowledgments

  • Inspired by the Marvel Cinematic Universe

Remember: With great power comes great responsibility. Use Thanos wisely! 🫰

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thanos_cli-0.2.1.tar.gz (73.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thanos_cli-0.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file thanos_cli-0.2.1.tar.gz.

File metadata

  • Download URL: thanos_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 73.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for thanos_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2706ed6f0eb1e6b674510ab303202d75b74a075c0c325ef8795a7c836f559173
MD5 f052b28904326544d5569b4c92200d32
BLAKE2b-256 44a779a1b94bcdf59a1cd88e47c7cd940727b7d5cf983c0b3b936ccffa7d03d7

See more details on using hashes here.

File details

Details for the file thanos_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: thanos_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for thanos_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87058fb91698a0dc3abbe3f05f6e901dfa7eaa8801b4785babfc47a1b9ef113c
MD5 74bb8c6077e8f3b40ecd53013f673cf8
BLAKE2b-256 1f941708a39d5a1e686746ce03c7c93dd79eafa9a3916078f707b655f74017a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page