Coverage for docs_src/commands/help/tutorial001.py: 100%
18 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(help="Awesome CLI user manager.") 1habcdefg
6@app.command() 1habcdefg
7def create(username: str): 1habcdefg
8 """
9 Create a new user with USERNAME.
10 """
11 print(f"Creating user: {username}") 1habcdefg
14@app.command() 1habcdefg
15def delete( 1abcdefg
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: 1habcdefg
29 print(f"Deleting user: {username}") 1habcdefg
30 else:
31 print("Operation cancelled") 1habcdefg
34@app.command() 1habcdefg
35def delete_all( 1abcdefg
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: 1habcdefg
48 print("Deleting all users") 1habcdefg
49 else:
50 print("Operation cancelled") 1habcdefg
53@app.command() 1habcdefg
54def init(): 1abcdefg
55 """
56 Initialize the users database.
57 """
58 print("Initializing user database") 1habcdefg
61if __name__ == "__main__": 1habcdefg
62 app() 1habcdefg