Coverage for docs_src/subcommands/callback_override/tutorial003.py: 100%
12 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
3app = typer.Typer() 1habcdefg
6def default_callback(): 1habcdefg
7 print("Running a users command") 1habcdefg
10users_app = typer.Typer(callback=default_callback) 1habcdefg
11app.add_typer(users_app, name="users") 1habcdefg
14@users_app.callback() 1habcdefg
15def user_callback(): 1abcdefg
16 print("Callback override, running users command") 1habcdefg
19@users_app.command() 1habcdefg
20def create(name: str): 1habcdefg
21 print(f"Creating user: {name}") 1habcdefg
24if __name__ == "__main__": 1habcdefg
25 app() 1habcdefg