Click Spinner
Click Spinner is a Python library that provides a simple context manager to display a spinning cursor in Click command-line interface (CLI) applications during long-running tasks where a precise progress bar isn't feasible. It aims to improve user experience by indicating activity. The library is currently at version 0.1.10 and is maintained as part of the `click-contrib` organization on GitHub.
Warnings
- gotcha Spinner characters are included in redirected stdout. When piping or redirecting the output of a command that uses `click-spinner` (e.g., `mycommand > output.txt`), the spinner characters will be written to the output file. This can interfere with machine-readable parsing or clean logs.
- gotcha Identical versions 0.1.9 and 0.1.10 on PyPI. Due to PyPI issues, versions `0.1.9` and `0.1.10` of `click-spinner` are functionally identical. Users should not expect any differences or new features between these two specific releases.
Install
-
pip install click-spinner
Imports
- spinner
from click_spinner import spinner
Quickstart
import time
from click_spinner import spinner
def long_running_task():
"""Simulates a task that takes some time."""
time.sleep(3) # Simulate 3 seconds of work
print("Starting a long task...")
with spinner():
long_running_task()
print("Task completed!")