pythonbeginner
Rich Progress Bar for CLI
Display beautiful progress bars and status spinners in CLI applications using the Rich library.
pythonPress ⌘/Ctrl + Shift + C to copy
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn
import time
def process_files(files: list[str]) -> None:
with Progress(
SpinnerColumn(),
TextColumn("[bold blue]{task.description}"),
BarColumn(),
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
TextColumn("({task.completed}/{task.total})"),
) as progress:
task = progress.add_task("Processing files", total=len(files))
for f in files:
# Simulate work
time.sleep(0.1)
progress.update(task, advance=1, description=f"Processing {f}")
# process_files(["file1.csv", "file2.csv", "file3.csv"])Use Cases
- Data processing scripts
- File download indicators
- Build step visualization
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
pythonbeginner
CLI Tool with argparse
Build a professional CLI tool with subcommands, typed arguments, environment variable fallbacks, and help text.
Best for: Developer tooling
#cli#argparse
pythonintermediate
Click CLI Command Group
Build professional CLI tools with Click using command groups, options, arguments, and help text.
Best for: Developer tools
#cli#click
pythonbeginner
Python CLI Tool with Argparse
Build a command-line tool with subcommands, arguments, validation, and help text using argparse.
Best for: Building developer tooling CLIs
#python#cli
typescriptbeginner
Interactive CLI with Readline
Build interactive command-line interfaces using Node.js readline with prompts, history, and auto-completion.
Best for: Building simple CLI tools
#nodejs#readline