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

6 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-04-14 00:18 +0000

1import typer 1iabcdefgh

2from typing_extensions import Annotated 1iabcdefgh

3 

4 

5def main( 1abcdefgh

6 name: str, 

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

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

9): 

10 """ 

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

12 

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

14 """ 

15 if formal: 1iabcdefgh

16 print(f"Good day Ms. {name} {lastname}.") 1iabcdefgh

17 else: 

18 print(f"Hello {name} {lastname}") 1iabcdefgh

19 

20 

21if __name__ == "__main__": 1iabcdefgh

22 typer.run(main) 1iabcdefgh