python-cli-patterns
SolidCLI application patterns for Python. Triggers on: cli, command line, typer, click, argparse, terminal, rich, console, terminal ui.
Data & Documents 422 stars
44 forks Updated today
Install
Quality Score: 86/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Python CLI Patterns
Modern CLI development with Typer and Rich.
## Basic Typer App
```python
import typer
app = typer.Typer(
name="myapp",
help="My awesome CLI application",
add_completion=True,
)
@app.command()
def hello(
name: str = typer.Argument(..., help="Name to greet"),
count: int = typer.Option(1, "--count", "-c", help="Times to greet"),
loud: bool = typer.Option(False, "--loud", "-l", help="Uppercase"),
):
"""Say hello to someone."""
message = f"Hello, {name}!"
if loud:
message = message.upper()
for _ in range(count):
typer.echo(message)
if __name__ == "__main__":
app()
```
## Command Groups
```python
import typer
app = typer.Typer()
users_app = typer.Typer(help="User management commands")
app.add_typer(users_app, name="users")
@users_app.command("list")
def list_users():
"""List all users."""
typer.echo("Listing users...")
@users_app.command("create")
def create_user(name: str, email: str):
"""Create a new user."""
typer.echo(f"Creating user: {name} <{email}>")
@app.command()
def version():
"""Show version."""
typer.echo("1.0.0")
# Usage: myapp users list
# myapp users create "John" "john@example.com"
# myapp version
```
## Rich Output
```python
from rich.console import Console
from rich.table import Table
from rich.progress import track
from rich.panel import Panel
import typer
console = Console()
@app.command()
def show_users():
"""Display users...
Details
- Author
- aiskillstore
- Repository
- aiskillstore/marketplace
- Created
- 8 months ago
- Last Updated
- today
- Language
- Python
- License
- None
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Solid
python-services
Python patterns for CLI tools, async parallelism, and backend services. Use when building CLI apps, async/parallel Python, FastAPI services, background jobs, or configuring Python project tooling (uv, ruff, ty).
31 Updated 1 weeks ago
iliaal AI & Automation Solid
python-typing-patterns
Python type hints and type safety patterns. Triggers on: type hints, typing, TypeVar, Generic, Protocol, mypy, pyright, type annotation, overload, TypedDict.
422 Updated today
aiskillstore Data & Documents Listed
python-patterns
Pythonic idioms, PEP 8 standards, type hints, and best practices for building robust, efficient, and maintainable Python applications.
0 Updated today
Izangi2714