Coverage for docs_src/commands/options/tutorial001.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
1import typer 1iabcdefgh
3app = typer.Typer() 1iabcdefgh
6@app.command() 1iabcdefgh
7def create(username: str): 1iabcdefgh
8 print(f"Creating user: {username}") 1iabcdefgh
11@app.command() 1iabcdefgh
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: 1iabcdefgh
17 print(f"Deleting user: {username}") 1iabcdefgh
18 else:
19 print("Operation cancelled") 1iabcdefgh
22@app.command() 1iabcdefgh
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: 1iabcdefgh
29 print("Deleting all users") 1iabcdefgh
30 else:
31 print("Operation cancelled") 1iabcdefgh
34@app.command() 1iabcdefgh
35def init(): 1abcdefgh
36 print("Initializing user database") 1iabcdefgh
39if __name__ == "__main__": 1iabcdefgh
40 app() 1iabcdefgh