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

7 statements  

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

1import typer 1abcdefghi

2 

3app = typer.Typer() 1abcdefghi

4 

5 

6@app.command() 1abcdefghi

7def main( 1abcdefghi

8 name: str, 

9 lastname: str = typer.Option("", help="Last name of person to greet."), 

10 formal: bool = typer.Option(False, help="Say hi formally."), 

11): 

12 """ 

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

14 

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

16 """ 

17 if formal: 1abcdefghi

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

19 else: 

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

21 

22 

23if __name__ == "__main__": 1abcdefghi

24 app() 1abcdefghi