Add first version of subcommands tutorial

This commit is contained in:
Sebastián Ramírez 2020-01-04 01:51:44 +01:00
parent d12d00e919
commit 7938d89d5e
4 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import typer
app = typer.Typer()
@app.command()
def create(item: str):
typer.echo(f"Creating item: {item}")
@app.command()
def delete(item: str):
typer.echo(f"Deleting item: {item}")
@app.command()
def sell(item: str):
typer.echo(f"Selling item: {item}")
if __name__ == "__main__":
app()

View file

@ -0,0 +1,10 @@
import typer
from . import items, users
app = typer.Typer()
app.add_typer(users.app, name="users")
app.add_typer(items.app, name="items")
if __name__ == "__main__":
app()

View file

@ -0,0 +1,17 @@
import typer
app = typer.Typer()
@app.command()
def create(user_name: str):
typer.echo(f"Creating user: {user_name}")
@app.command()
def delete(user_name: str):
typer.echo(f"Deleting user: {user_name}")
if __name__ == "__main__":
app()