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

8 statements  

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

1import typer 1abcdefghij

2 

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

4 

5 

6@app.command() 1abcdefghij

7def create( 1abcdefghij

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}") 1abcdefghij

26 

27 

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

29def config(configuration: str): 1abcdefghij

30 """ 

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

32 """ 

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

34 

35 

36if __name__ == "__main__": 1abcdefghij

37 app() 1abcdefghij