Coverage for docs_src / commands / help / tutorial005_an_py39.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-02-09 12:36 +0000

1from typing import Annotated 1abcdefgh

2 

3import typer 1abcdefgh

4 

5app = typer.Typer(rich_markup_mode="markdown") 1abcdefgh

6 

7 

8@app.command() 1abcdefgh

9def create( 1abcdefgh

10 username: Annotated[str, typer.Argument(help="The username to be **created**")], 

11): 

12 """ 

13 **Create** a new *shiny* user. :sparkles: 

14 

15 * Create a username 

16 

17 * Show that the username is created 

18 

19 --- 

20 

21 Learn more at the [Typer docs website](https://typer.tiangolo.com) 

22 """ 

23 print(f"Creating user: {username}") 1abcdefgh

24 

25 

26@app.command(help="**Delete** a user with *USERNAME*.") 1abcdefgh

27def delete( 1abcdefgh

28 username: Annotated[str, typer.Argument(help="The username to be **deleted**")], 

29 force: Annotated[bool, typer.Option(help="Force the **deletion** :boom:")] = False, 

30): 

31 """ 

32 Some internal utility function to delete. 

33 """ 

34 print(f"Deleting user: {username}") 1abcdefgh

35 

36 

37if __name__ == "__main__": 1abcdefgh

38 app() 1abcdefgh