Loading...
Loading...
Use when building or structuring Python CLI commands with Typer, including commands, options, and multi-command apps.
npx skill4agent add narumiruna/telegram-bot python-cli-typeruv add typer| Task | Pattern |
|---|---|
| Single command | |
| Options | function args with defaults |
| Multiple commands | multiple |
typer.Typer()cli.pyuv run python -m <module>uv run python cli.pyimport typer
app = typer.Typer()
@app.command()
def greet(name: str, count: int = 1) -> None:
for _ in range(count):
typer.echo(f"Hello, {name}!")
if __name__ == "__main__":
app()uv run python cli.py --help
uv run python cli.py Alice
uv run python cli.py Alice --count 3import typer
app = typer.Typer()
@app.command()
def create(name: str) -> None:
"""Create a new item."""
typer.echo(f"Creating {name}...")
@app.command()
def delete(name: str, force: bool = False) -> None:
"""Delete an item."""
if not force:
if not typer.confirm(f"Delete {name}?"):
raise typer.Abort()
typer.echo(f"Deleted {name}")
if __name__ == "__main__":
app()if __name__ == "__main__"