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

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-19 20:29 +0000

1import typer 1abcdefghi

2from typing_extensions import Annotated 1abcdefghi

3 

4app = typer.Typer() 1abcdefghi

5 

6 

7@app.command() 1abcdefghi

8def main( 1abcdefghi

9 name: str, 

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

11 formal: Annotated[bool, typer.Option(help="Say hi formally.")] = False, 

12): 

13 """ 

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

15 

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

17 """ 

18 if formal: 1abcdefghi

19 print(f"Good day Ms. {name} {lastname}.") 1abcdefghi

20 else: 

21 print(f"Hello {name} {lastname}") 1abcdefghi

22 

23 

24if __name__ == "__main__": 1abcdefghi

25 app() 1abcdefghi