Coverage for docs_src/options/help/tutorial001_an.py: 100%
6 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1import typer 1habcdefg
2from typing_extensions import Annotated 1habcdefg
5def main( 1abcdefg
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.
13 If --formal is used, say hi very formally.
14 """
15 if formal: 1habcdefg
16 print(f"Good day Ms. {name} {lastname}.") 1habcdefg
17 else:
18 print(f"Hello {name} {lastname}") 1habcdefg
21if __name__ == "__main__": 1habcdefg
22 typer.run(main) 1habcdefg