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