annotations
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| Short slashed.annotations Marker for parameter shorthand. |
🛈 DocStrings¶
Annotations for command parameters.
Short
dataclass
¶
Marker for parameter shorthand.
Use with Annotated to define single-character shortcuts for command parameters.
Example
from typing import Annotated
from slashed import SlashedCommand, Short
class MyCommand(SlashedCommand):
name = "greet"
async def execute_command(
self,
name: str,
verbose: Annotated[bool, Short("v")] = False,
output: Annotated[str, Short("o")] = "stdout",
):
...
Now the command can be invoked as:
- /greet John --verbose true
- /greet John -v true
- /greet John -o file.txt -v true
Source code in src/slashed/annotations.py
__post_init__
¶
Validate the shorthand character.