Coverage for docs_src / options / version / tutorial001_non_an.py: 100%

10 statements  

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

1import typer 1abcdefghij

2 

3__version__ = "0.1.0" 1abcdefghij

4 

5app = typer.Typer() 1abcdefghij

6 

7 

8def version_callback(value: bool): 1abcdefghij

9 if value: 1abcdefghij

10 print(f"Awesome CLI Version: {__version__}") 1abcdefghij

11 raise typer.Exit() 1abcdefghij

12 

13 

14@app.command() 1abcdefghij

15def main( 1abcdefghij

16 name: str = typer.Option("World"), 

17 version: bool | None = typer.Option(None, "--version", callback=version_callback), 

18): 

19 print(f"Hello {name}") 1abcdefghij

20 

21 

22if __name__ == "__main__": 1abcdefghij

23 app() 1abcdefghij