Coverage for docs_src/options/help/tutorial002_an.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
« 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
4app = typer.Typer() 1abcdefghi
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[
12 bool,
13 typer.Option(
14 help="Say hi formally.", rich_help_panel="Customization and Utils"
15 ),
16 ] = False,
17 debug: Annotated[
18 bool,
19 typer.Option(
20 help="Enable debugging.", rich_help_panel="Customization and Utils"
21 ),
22 ] = False,
23):
24 """
25 Say hi to NAME, optionally with a --lastname.
27 If --formal is used, say hi very formally.
28 """
29 if formal: 1abcdefghi
30 print(f"Good day Ms. {name} {lastname}.") 1abcdefghi
31 else:
32 print(f"Hello {name} {lastname}") 1abcdefghi
35if __name__ == "__main__": 1abcdefghi
36 app() 1abcdefghi