Skip to content

Commit

Permalink
⏪️ Revert inlining example for typer command, as this is no longer th…
Browse files Browse the repository at this point in the history
…e README for typer-cli
  • Loading branch information
tiangolo committed Mar 30, 2024
1 parent ab3f782 commit a4d2021
Showing 1 changed file with 1 addition and 67 deletions.
68 changes: 1 addition & 67 deletions docs/tutorial/typer-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,73 +242,7 @@ You can also use the `typer` command to generate Markdown documentation for your
For example, you could have a script like:

```Python
import typer
from typing_extensions import Annotated

app = typer.Typer(help="Awesome CLI user manager.")


@app.command()
def create(username: str):
"""
Create a new user with USERNAME.
"""
print(f"Creating user: {username}")


@app.command()
def delete(
username: str,
force: Annotated[
bool,
typer.Option(
prompt="Are you sure you want to delete the user?",
help="Force deletion without confirmation.",
),
],
):
"""
Delete a user with USERNAME.
If --force is not used, will ask for confirmation.
"""
if force:
print(f"Deleting user: {username}")
else:
print("Operation cancelled")


@app.command()
def delete_all(
force: Annotated[
bool,
typer.Option(
prompt="Are you sure you want to delete ALL users?",
help="Force deletion without confirmation.",
),
],
):
"""
Delete ALL users in the database.
If --force is not used, will ask for confirmation.
"""
if force:
print("Deleting all users")
else:
print("Operation cancelled")


@app.command()
def init():
"""
Initialize the users database.
"""
print("Initializing user database")


if __name__ == "__main__":
app()
{!../docs_src/commands/help/tutorial001.py!}
```

### Generate docs with the `typer` command
Expand Down

0 comments on commit a4d2021

Please sign in to comment.