Coverage for docs_src/commands/help/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(help="Awesome CLI user manager.") 1abcdefghi
6@app.command() 1abcdefghi
7def create(username: str): 1abcdefghi
8 """
9 Create a new user with USERNAME.
10 """
11 print(f"Creating user: {username}") 1abcdefghi
14@app.command() 1abcdefghi
15def delete( 1abcdefghi
16 username: str,
17 force: bool = typer.Option(
18 ...,
19 prompt="Are you sure you want to delete the user?",
20 help="Force deletion without confirmation.",
21 ),
22):
23 """
24 Delete a user with USERNAME.
26 If --force is not used, will ask for confirmation.
27 """
28 if force: 1abcdefghi
29 print(f"Deleting user: {username}") 1abcdefghi
30 else:
31 print("Operation cancelled") 1abcdefghi
34@app.command() 1abcdefghi
35def delete_all( 1abcdefghi
36 force: bool = typer.Option(
37 ...,
38 prompt="Are you sure you want to delete ALL users?",
39 help="Force deletion without confirmation.",
40 ),
41):
42 """
43 Delete ALL users in the database.
45 If --force is not used, will ask for confirmation.
46 """
47 if force: 1abcdefghi
48 print("Deleting all users") 1abcdefghi
49 else:
50 print("Operation cancelled") 1abcdefghi
53@app.command() 1abcdefghi
54def init(): 1abcdefghi
55 """
56 Initialize the users database.
57 """
58 print("Initializing user database") 1abcdefghi
61if __name__ == "__main__": 1abcdefghi
62 app() 1abcdefghi