Coverage for docs_src / commands / help / tutorial007_an_py39.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-02-09 12:36 +0000

1from typing import Annotated, Union 1abcdefgh

2 

3import typer 1abcdefgh

4 

5app = typer.Typer(rich_markup_mode="rich") 1abcdefgh

6 

7 

8@app.command() 1abcdefgh

9def create( 1abcdefgh

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 Union[int, None], 

20 typer.Option(help="The age of the new user", rich_help_panel="Additional Data"), 

21 ] = None, 

22 favorite_color: Annotated[ 

23 Union[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}") 1abcdefgh

34 

35 

36@app.command(rich_help_panel="Utils and Configs") 1abcdefgh

37def config(configuration: str): 1abcdefgh

38 """ 

39 [blue]Configure[/blue] the system. :gear: 

40 """ 

41 print(f"Configuring the system with: {configuration}") 1abcdefgh

42 

43 

44if __name__ == "__main__": 1abcdefgh

45 app() 1abcdefgh