Coverage for docs_src/commands/help/tutorial004_an.py: 100%
9 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-14 00:18 +0000
1import typer 1iabcdefgh
2from typing_extensions import Annotated 1iabcdefgh
4app = typer.Typer(rich_markup_mode="rich") 1iabcdefgh
7@app.command() 1iabcdefgh
8def create( 1abcdefgh
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:
16 This requires a [underline]username[/underline].
17 """
18 print(f"Creating user: {username}") 1iabcdefgh
21@app.command(help="[bold red]Delete[/bold red] a user with [italic]USERNAME[/italic].") 1iabcdefgh
22def delete( 1abcdefgh
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}") 1iabcdefgh
36if __name__ == "__main__": 1iabcdefgh
37 app() 1iabcdefgh