Coverage for docs_src/commands/callback/tutorial003.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 18:26 +0000

1import typer 1habcdefg

2 

3 

4def callback(): 1habcdefg

5 print("Running a command") 1habcdefg

6 

7 

8app = typer.Typer(callback=callback) 1habcdefg

9 

10 

11@app.callback() 1habcdefg

12def new_callback(): 1abcdefg

13 print("Override callback, running a command") 1habcdefg

14 

15 

16@app.command() 1habcdefg

17def create(name: str): 1habcdefg

18 print(f"Creating user: {name}") 1habcdefg

19 

20 

21if __name__ == "__main__": 1habcdefg

22 app() 1habcdefg