$ show andreafrancia/trash-cli
trash-cli is a command-line interface implementing the FreeDesktop.org Trash specification. It provides five primary commands: trash-put (move files to trash), trash-list (list trashed files), trash-restore (interactively restore files), trash-empty (empty trash directories), and trash-rm (remove specific trashed files). The architecture is modular, with separate packages for each command (trashcli/put/, trashcli/list/, trashcli/restore/, trashcli/empty/, trashcli/rm/) sharing common utilities from trashcli/lib/, trashcli/fslib/, and trashcli/fstab/. Key entry points are the main() functions in each command's main.py module, invoked via shell scripts (trash, trash-put, etc.). Data flows involve reading trash directories (per the spec's rules for $XDG_DATA_HOME/Trash, .Trash/$uid, .Trash-$uid), parsing .trashinfo files, and performing file operations (move, delete, restore) with security checks (sticky bits, symlinks, world-writable directories). External dependencies include psutil (for volume detection), six (Python 2/3 compatibility), and optionally shtab (shell completion). The codebase is well-tested with a comprehensive fake filesystem for unit tests and integration tests covering edge cases.
The LLM identified 4 files worth highlighting for reuse:
Implements an Either monad (Left/Right) for error handling in the trash-put pipeline. Provides map, bind, and other functional combinators. This is a clean, self-contained pattern that can be extracted and reused in any Python project requiring explicit error handling without exceptions.
Defines protocol-based abstractions for filesystem operations (ContentsOf, Move, AtomicWrite, etc.) using Python's typing.Protocol. This decouples filesystem logic from concrete implementations, enabling easy testing and swapping of backends. The pattern is reusable for any project needing a clean filesystem abstraction layer.
A comprehensive fake filesystem for unit testing that simulates directories, files, symlinks, permissions, and sticky bits. Supports operations like listdir, walk, stat, readlink, and makedirs. This is a reusable testing utility that can be extracted and adapted for any project requiring filesystem simulation without touching the real OS.
Provides a structured logging framework with LogEntry, Level, and LogTag classes. Logs are tagged with categories (e.g., 'trash_put', 'security_check') and levels (debug, info, warning, error). This pattern is self-contained and can be reused in any Python application needing structured, taggable logging.