Coverage for docs_src / options / version / tutorial001_an_py39.py: 100%
11 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1from typing import Annotated, Optional 1abcdefgh
3import typer 1abcdefgh
5__version__ = "0.1.0" 1abcdefgh
7app = typer.Typer() 1abcdefgh
10def version_callback(value: bool): 1abcdefgh
11 if value: 1abcdefgh
12 print(f"Awesome CLI Version: {__version__}") 1abcdefgh
13 raise typer.Exit() 1abcdefgh
16@app.command() 1abcdefgh
17def main( 1abcdefgh
18 name: Annotated[str, typer.Option()] = "World",
19 version: Annotated[
20 Optional[bool], typer.Option("--version", callback=version_callback)
21 ] = None,
22):
23 print(f"Hello {name}") 1abcdefgh
26if __name__ == "__main__": 1abcdefgh
27 app() 1abcdefgh