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

8 statements  

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

1import typer 1habcdefg

2 

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

4 

5 

6@app.command() 1habcdefg

7def create( 1abcdefg

8 username: str = typer.Argument( 

9 ..., help="The username to be [green]created[/green]" 

10 ), 

11): 

12 """ 

13 [bold green]Create[/bold green] a new [italic]shiny[/italic] user. :sparkles: 

14 

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

16 """ 

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

18 

19 

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

21def delete( 1abcdefg

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

23 force: bool = typer.Option( 

24 False, help="Force the [bold red]deletion[/bold red] :boom:" 

25 ), 

26): 

27 """ 

28 Some internal utility function to delete. 

29 """ 

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

31 

32 

33if __name__ == "__main__": 1habcdefg

34 app() 1habcdefg