Coverage for docs_src / commands / help / tutorial007_an_py310.py: 100%
9 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1from typing import Annotated 1abcdefg
3import typer 1abcdefg
5app = typer.Typer(rich_markup_mode="rich") 1abcdefg
8@app.command() 1abcdefg
9def create( 1abcdefg
10 username: Annotated[str, typer.Argument(help="The username to create")],
11 lastname: Annotated[
12 str,
13 typer.Argument(
14 help="The last name of the new user", rich_help_panel="Secondary Arguments"
15 ),
16 ] = "",
17 force: Annotated[bool, typer.Option(help="Force the creation of the user")] = False,
18 age: Annotated[
19 int | None,
20 typer.Option(help="The age of the new user", rich_help_panel="Additional Data"),
21 ] = None,
22 favorite_color: Annotated[
23 str | None,
24 typer.Option(
25 help="The favorite color of the new user",
26 rich_help_panel="Additional Data",
27 ),
28 ] = None,
29):
30 """
31 [green]Create[/green] a new user. :sparkles:
32 """
33 print(f"Creating user: {username}") 1abcdefg
36@app.command(rich_help_panel="Utils and Configs") 1abcdefg
37def config(configuration: str): 1abcdefg
38 """
39 [blue]Configure[/blue] the system. :gear:
40 """
41 print(f"Configuring the system with: {configuration}") 1abcdefg
44if __name__ == "__main__": 1abcdefg
45 app() 1abcdefg