Defining routes
Use@cli.command("<pattern>") with typed parameters that match the placeholders in your pattern:
<type:name> placeholders describe both the argument type and the name passed into your function. Missing or malformed args produce clear, typed errors automatically.
Typing and validation
- Built-in converters include
str,int,bool,float,url,uuid, andjson. - Convert user input before your function runs, so you only handle validated Python types.
- Custom converters are easy—see Type Converters.
Root vs. subcommands
@cli.roothandlesrunegraftwith no args (perfect for launching the shell).- Routes can nest to mimic subcommands:
config setandconfig getshare theconfigprefix but map to different functions.
Helpful output for free
- Help text is generated from your route strings and docstrings.
- Missing/extra argument errors are formatted automatically and show expected types and options.
- Combine with Options & Flags to offer defaults, choices, and aliases without hand-writing parsers.