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

7 statements  

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

1import typer 1abcdefghij

2 

3app = typer.Typer() 1abcdefghij

4 

5 

6@app.command() 1abcdefghij

7def main( 1abcdefghij

8 name: str, 

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

10 formal: bool = typer.Option( 

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

12 ), 

13 debug: bool = typer.Option( 

14 False, help="Enable debugging.", rich_help_panel="Customization and Utils" 

15 ), 

16): 

17 """ 

18 Say hi to 'name', optionally with a --lastname. 

19 

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

21 """ 

22 if formal: 1abcdefghij

23 print(f"Good day Ms. {name} {lastname}.") 1abcdefghij

24 else: 

25 print(f"Hello {name} {lastname}") 1abcdefghij

26 

27 

28if __name__ == "__main__": 1abcdefghij

29 app() 1abcdefghij