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

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 18:26 +0000

1import typer 1habcdefg

2from typing_extensions import Annotated 1habcdefg

3 

4app = typer.Typer(rich_markup_mode="rich") 1habcdefg

5 

6 

7@app.command() 1habcdefg

8def create( 1abcdefg

9 username: Annotated[ 

10 str, typer.Argument(help="The username to be [green]created[/green]") 

11 ], 

12): 

13 """ 

14 [bold green]Create[/bold green] a new [italic]shinny[/italic] user. :sparkles: 

15 

16 This requires a [underline]username[/underline]. 

17 """ 

18 print(f"Creating user: {username}") 1habcdefg

19 

20 

21@app.command(help="[bold red]Delete[/bold red] a user with [italic]USERNAME[/italic].") 1habcdefg

22def delete( 1abcdefg

23 username: Annotated[ 

24 str, typer.Argument(help="The username to be [red]deleted[/red]") 

25 ], 

26 force: Annotated[ 

27 bool, typer.Option(help="Force the [bold red]deletion[/bold red] :boom:") 

28 ] = False, 

29): 

30 """ 

31 Some internal utility function to delete. 

32 """ 

33 print(f"Deleting user: {username}") 1habcdefg

34 

35 

36if __name__ == "__main__": 1habcdefg

37 app() 1habcdefg