✨ Add first version of subcommands tutorial
This commit is contained in:
parent
d12d00e919
commit
7938d89d5e
4 changed files with 49 additions and 0 deletions
0
docs/src/subcommands/tutorial001/app/__init__.py
Normal file
0
docs/src/subcommands/tutorial001/app/__init__.py
Normal file
22
docs/src/subcommands/tutorial001/app/items.py
Normal file
22
docs/src/subcommands/tutorial001/app/items.py
Normal 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()
|
10
docs/src/subcommands/tutorial001/app/main.py
Normal file
10
docs/src/subcommands/tutorial001/app/main.py
Normal 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()
|
17
docs/src/subcommands/tutorial001/app/users.py
Normal file
17
docs/src/subcommands/tutorial001/app/users.py
Normal 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()
|
Loading…
Reference in a new issue