Coverage for docs_src / commands / options / tutorial001_py39.py: 100%
18 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
1import typer 1abcdefgh
3app = typer.Typer() 1abcdefgh
6@app.command() 1abcdefgh
7def create(username: str): 1abcdefgh
8 print(f"Creating user: {username}") 1abcdefgh
11@app.command() 1abcdefgh
12def delete( 1abcdefgh
13 username: str,
14 force: bool = typer.Option(..., prompt="Are you sure you want to delete the user?"),
15):
16 if force: 1abcdefgh
17 print(f"Deleting user: {username}") 1abcdefgh
18 else:
19 print("Operation cancelled") 1abcdefgh
22@app.command() 1abcdefgh
23def delete_all( 1abcdefgh
24 force: bool = typer.Option(
25 ..., prompt="Are you sure you want to delete ALL users?"
26 ),
27):
28 if force: 1abcdefgh
29 print("Deleting all users") 1abcdefgh
30 else:
31 print("Operation cancelled") 1abcdefgh
34@app.command() 1abcdefgh
35def init(): 1abcdefgh
36 print("Initializing user database") 1abcdefgh
39if __name__ == "__main__": 1abcdefgh
40 app() 1abcdefgh