Coverage for docs_src/commands/options/tutorial001.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
1import typer 1abcdefghi
3app = typer.Typer() 1abcdefghi
6@app.command() 1abcdefghi
7def create(username: str): 1abcdefghi
8 print(f"Creating user: {username}") 1abcdefghi
11@app.command() 1abcdefghi
12def delete( 1abcdefghi
13 username: str,
14 force: bool = typer.Option(..., prompt="Are you sure you want to delete the user?"),
15):
16 if force: 1abcdefghi
17 print(f"Deleting user: {username}") 1abcdefghi
18 else:
19 print("Operation cancelled") 1abcdefghi
22@app.command() 1abcdefghi
23def delete_all( 1abcdefghi
24 force: bool = typer.Option(
25 ..., prompt="Are you sure you want to delete ALL users?"
26 ),
27):
28 if force: 1abcdefghi
29 print("Deleting all users") 1abcdefghi
30 else:
31 print("Operation cancelled") 1abcdefghi
34@app.command() 1abcdefghi
35def init(): 1abcdefghi
36 print("Initializing user database") 1abcdefghi
39if __name__ == "__main__": 1abcdefghi
40 app() 1abcdefghi