-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_51.py
More file actions
45 lines (32 loc) · 1.15 KB
/
Copy pathexample_51.py
File metadata and controls
45 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import typer
from typing_extensions import Annotated
"""See https://typer.tiangolo.com/tutorial/commands/help/"""
# Rich Markdown
# If you set `rich_markup_mode="markdown"` when creating the `typer.Typer()`
# app, you will be able to use Markdown in the docstring
# Notice how you can use Markdown in the help text overwritten for the
# command `delete` just as before.
app = typer.Typer(rich_markup_mode="markdown")
@app.command()
def create(
username: Annotated[str, typer.Argument(help="The username to be **created**")],
):
"""
**Create** a new *shinny* user. :sparkles:
* Create a username
* Show that the username is created
---
Learn more at the [Typer docs website](https://typer.tiangolo.com)
"""
print(f"Creating user: {username}")
@app.command(help="**Delete** a user with *USERNAME*.")
def delete(
username: Annotated[str, typer.Argument(help="The username to be **deleted**")],
force: Annotated[bool, typer.Option(help="Force the **deletion** :boom:")] = False,
):
"""
Some internal utility function to delete.
"""
print(f"Deleting user: {username}")
if __name__ == "__main__":
app()