$ show click-contrib/click-spinner
Click-spinner is a minimal Python library that provides a terminal spinner interface for indicating progress during long-running operations where the duration is unknown. The core functionality resides in the Spinner class, which runs a background thread to animate a sequence of characters (spinner frames) while the main thread executes work. The spinner automatically detects whether output is redirected and respects terminal capabilities, with options to force display, disable the spinner, or emit a beep upon completion. Designed as a context manager, it integrates seamlessly with Click-based CLI applications but has no framework dependencies, relying solely on Python's standard library. The project includes comprehensive test coverage verifying behavior under various conditions like output redirection, disabling, and exception handling, supported by CI workflows testing across Python 3.8-3.14.
The LLM identified 1 files worth highlighting for reuse:
The Spinner class implements a thread-safe terminal spinner using itertools.cycle for animation frames and threading.Event for clean termination. It demonstrates non-obvious skill in managing background threads, handling stream redirection (TTY detection), and providing a robust context manager interface. The component is completely self-contained with zero external dependencies, making it trivially reusable in any Python CLI project requiring progress indication.