Coverage for docs_src / options / help / tutorial002_an_py39.py: 100%

8 statements  

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

1from typing import Annotated 1abcdefgh

2 

3import typer 1abcdefgh

4 

5app = typer.Typer() 1abcdefgh

6 

7 

8@app.command() 1abcdefgh

9def main( 1abcdefgh

10 name: str, 

11 lastname: Annotated[str, typer.Option(help="Last name of person to greet.")] = "", 

12 formal: Annotated[ 

13 bool, 

14 typer.Option( 

15 help="Say hi formally.", rich_help_panel="Customization and Utils" 

16 ), 

17 ] = False, 

18 debug: Annotated[ 

19 bool, 

20 typer.Option( 

21 help="Enable debugging.", rich_help_panel="Customization and Utils" 

22 ), 

23 ] = False, 

24): 

25 """ 

26 Say hi to NAME, optionally with a --lastname. 

27 

28 If --formal is used, say hi very formally. 

29 """ 

30 if formal: 1abcdefgh

31 print(f"Good day Ms. {name} {lastname}.") 1abcdefgh

32 else: 

33 print(f"Hello {name} {lastname}") 1abcdefgh

34 

35 

36if __name__ == "__main__": 1abcdefgh

37 app() 1abcdefgh