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

8 statements  

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

1import typer 1abcdefg

2 

3app = typer.Typer(rich_markup_mode="rich") 1abcdefg

4 

5 

6@app.command() 1abcdefg

7def create( 1abcdefg

8 username: str = typer.Argument(..., help="The username to create"), 

9 lastname: str = typer.Argument( 

10 "", help="The last name of the new user", rich_help_panel="Secondary Arguments" 

11 ), 

12 force: bool = typer.Option(False, help="Force the creation of the user"), 

13 age: int | None = typer.Option( 

14 None, help="The age of the new user", rich_help_panel="Additional Data" 

15 ), 

16 favorite_color: str | None = typer.Option( 

17 None, 

18 help="The favorite color of the new user", 

19 rich_help_panel="Additional Data", 

20 ), 

21): 

22 """ 

23 [green]Create[/green] a new user. :sparkles: 

24 """ 

25 print(f"Creating user: {username}") 1abcdefg

26 

27 

28@app.command(rich_help_panel="Utils and Configs") 1abcdefg

29def config(configuration: str): 1abcdefg

30 """ 

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

32 """ 

33 print(f"Configuring the system with: {configuration}") 1abcdefg

34 

35 

36if __name__ == "__main__": 1abcdefg

37 app() 1abcdefg