Skip to content

How-to: Add a Command

Goal

Add a new command with typed options and help text.

Steps

  1. Define command on your app.
from sayer import Sayer, Option

app = Sayer()


@app.command()
def sync_users(limit: int = Option(100, help="Maximum users to sync")):
    print(f"Syncing {limit} users")
  1. Run it.
python app.py sync-users --limit 200
  1. Verify help.
python app.py sync-users --help

Notes

  • Command names default to kebab-case from function names.
  • Prefer explicit help= for every user-facing parameter.